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

View file

@ -320,8 +320,8 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
if (obfuscate) if (obfuscate)
if (_columns[c]->type () == "string") if (_columns[c]->type () == "string")
for (unsigned int line = 0; line < cells[c].size (); ++line) for (auto & line : cells[c])
cells[c][line] = obfuscateText (cells[c][line]); line = obfuscateText (line);
} }
// Listing breaks are simply blank lines inserted when a column value // 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 // This is a basic depth first search that always terminates given the
// fact that we do not visit any task twice // 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"); auto current_uuid = current.get ("uuid");