diff options
author | Artur Ryt <artur.ryt@gmail.com> | 2019-02-07 21:39:05 (GMT) |
---|---|---|
committer | Artur Ryt <artur.ryt@gmail.com> | 2019-02-07 21:39:05 (GMT) |
commit | 01b2d6ab7465e7f22fb821876027df86b0c8f363 (patch) | |
tree | 7ae313670e3655269ef7f9db6feabdc4bb2aaf25 /Source/cmMakefile.cxx | |
parent | 15bdbec0176e3aa620bb5bda3631819c5ca18eaf (diff) | |
download | CMake-01b2d6ab7465e7f22fb821876027df86b0c8f363.zip CMake-01b2d6ab7465e7f22fb821876027df86b0c8f363.tar.gz CMake-01b2d6ab7465e7f22fb821876027df86b0c8f363.tar.bz2 |
Modernize: Use ranged for-loops when possible
Replaced most manual `const_iterator`-based loops and some
reverse-iterator loops with range loops.
Fixes: #18858
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index cc61318..3d22f57 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -292,13 +292,14 @@ void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const std::string const& only_filename = cmSystemTools::GetFilenameName(full_path); bool trace = trace_only_this_files.empty(); if (!trace) { - for (std::vector<std::string>::const_iterator i = - trace_only_this_files.begin(); - !trace && i != trace_only_this_files.end(); ++i) { - std::string::size_type const pos = full_path.rfind(*i); + for (std::string const& file : trace_only_this_files) { + std::string::size_type const pos = full_path.rfind(file); trace = (pos != std::string::npos) && - ((pos + i->size()) == full_path.size()) && - (only_filename == cmSystemTools::GetFilenameName(*i)); + ((pos + file.size()) == full_path.size()) && + (only_filename == cmSystemTools::GetFilenameName(file)); + if (trace) { + break; + } } // Do nothing if current file wasn't requested for trace... if (!trace) { @@ -1848,10 +1849,8 @@ void cmMakefile::CheckForUnusedVariables() const if (!this->WarnUnused) { return; } - const std::vector<std::string>& unused = this->StateSnapshot.UnusedKeys(); - std::vector<std::string>::const_iterator it = unused.begin(); - for (; it != unused.end(); ++it) { - this->LogUnused("out of scope", *it); + for (const std::string& key : this->StateSnapshot.UnusedKeys()) { + this->LogUnused("out of scope", key); } } @@ -3055,10 +3054,8 @@ bool cmMakefile::IsFunctionBlocked(const cmListFileFunction& lff, // loop over all function blockers to see if any block this command // evaluate in reverse, this is critical for balanced IF statements etc - std::vector<cmFunctionBlocker*>::reverse_iterator pos; - for (pos = this->FunctionBlockers.rbegin(); - pos != this->FunctionBlockers.rend(); ++pos) { - if ((*pos)->IsFunctionBlocked(lff, *this, status)) { + for (cmFunctionBlocker* pos : cmReverseRange(this->FunctionBlockers)) { + if (pos->IsFunctionBlocked(lff, *this, status)) { return true; } } |