[clang-tidy] Use new range based loops

Found with modernize-loop-convert

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2019-09-27 19:20:23 -07:00 committed by Paul Beckingham
parent 6ce2a129dd
commit a468537c1b
4 changed files with 20 additions and 20 deletions

View file

@ -534,8 +534,8 @@ int Context::initialize (int argc, const char** argv)
//
////////////////////////////////////////////////////////////////////////////
for (unsigned int i = 0; i < NUM_MODIFIER_NAMES; ++i)
cli2.entity ("modifier", modifierNames[i]);
for (auto & modifierName : modifierNames)
cli2.entity ("modifier", modifierName);
for (auto& op : Eval::getOperators ())
cli2.entity ("operator", op);

View file

@ -195,8 +195,8 @@ void Eval::debug (bool value)
std::vector <std::string> Eval::getOperators ()
{
std::vector <std::string> all;
for (unsigned int i = 0; i < NUM_OPERATORS; ++i)
all.push_back (operators[i].op);
for (auto & i : operators)
all.push_back (i.op);
return all;
}
@ -206,9 +206,9 @@ std::vector <std::string> Eval::getOperators ()
std::vector <std::string> Eval::getBinaryOperators ()
{
std::vector <std::string> all;
for (unsigned int i = 0; i < NUM_OPERATORS; ++i)
if (operators[i].type == 'b')
all.push_back (operators[i].op);
for (auto & i : operators)
if (i.type == 'b')
all.push_back (i.op);
return all;
}
@ -338,9 +338,9 @@ void Eval::evaluatePostfixStack (
case Lexer::Type::identifier:
{
bool found = false;
for (auto source = _sources.begin (); source != _sources.end (); ++source)
for (auto _source : _sources)
{
if ((*source) (token.first, v))
if (_source (token.first, v))
{
if (_debug)
Context::getContext ().debug (format ("Eval identifier source '{1}' → ↑'{2}'", token.first, (std::string) v));
@ -669,10 +669,10 @@ bool Eval::parsePrimitive (
else
{
bool found = false;
for (auto source = _sources.begin (); source != _sources.end (); ++source)
for (auto _source : _sources)
{
Variant v;
if ((*source) (infix[i].first, v))
if (_source (infix[i].first, v))
{
found = true;
break;
@ -810,13 +810,13 @@ bool Eval::identifyOperator (
unsigned int& precedence,
char& associativity) const
{
for (unsigned int i = 0; i < NUM_OPERATORS; ++i)
for (auto & i : operators)
{
if (operators[i].op == op)
if (i.op == op)
{
type = operators[i].type;
precedence = operators[i].precedence;
associativity = operators[i].associativity;
type = i.type;
precedence = i.precedence;
associativity = i.associativity;
return true;
}
}

View file

@ -320,8 +320,8 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
if (obfuscate)
if (_columns[c]->type () == "string")
for (unsigned int line = 0; line < cells[c].size (); ++line)
cells[c][line] = obfuscateText (cells[c][line]);
for (auto & line : cells[c])
line = obfuscateText (line);
}
// Listing breaks are simply blank lines inserted when a column value

View file

@ -91,9 +91,9 @@ bool dependencyIsCircular (const Task& task)
// This is a basic depth first search that always terminates given the
// fact that we do not visit any task twice
for (unsigned int i = 0; i < deps_current.size (); i++)
for (const auto & i : deps_current)
{
if (Context::getContext ().tdb2.get (deps_current[i], current))
if (Context::getContext ().tdb2.get (i, current))
{
auto current_uuid = current.get ("uuid");