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/cmComputeLinkDepends.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/cmComputeLinkDepends.cxx')
-rw-r--r-- | Source/cmComputeLinkDepends.cxx | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 4717cf6..5ed6c29 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -256,11 +256,7 @@ cmComputeLinkDepends::Compute() // Iterate in reverse order so we can keep only the last occurrence // of a shared library. std::set<int> emmitted; - for (std::vector<int>::const_reverse_iterator - li = this->FinalLinkOrder.rbegin(), - le = this->FinalLinkOrder.rend(); - li != le; ++li) { - int i = *li; + for (int i : cmReverseRange(this->FinalLinkOrder)) { LinkEntry const& e = this->EntryList[i]; cmGeneratorTarget const* t = e.Target; // Entries that we know the linker will re-use do not need to be repeated. @@ -586,11 +582,10 @@ void cmComputeLinkDepends::InferDependencies() } // Intersect the sets for this item. - DependSetList::const_iterator i = sets->begin(); - DependSet common = *i; - for (++i; i != sets->end(); ++i) { + DependSet common = sets->front(); + for (DependSet const& i : cmMakeRange(*sets).advance(1)) { DependSet intersection; - std::set_intersection(common.begin(), common.end(), i->begin(), i->end(), + std::set_intersection(common.begin(), common.end(), i.begin(), i.end(), std::inserter(intersection, intersection.begin())); common = intersection; } @@ -708,9 +703,8 @@ void cmComputeLinkDepends::VisitComponent(unsigned int c) // Run in reverse order so the topological order will preserve the // original order where there are no constraints. EdgeList const& nl = this->CCG->GetComponentGraphEdges(c); - for (EdgeList::const_reverse_iterator ni = nl.rbegin(); ni != nl.rend(); - ++ni) { - this->VisitComponent(*ni); + for (cmGraphEdge const& edge : cmReverseRange(nl)) { + this->VisitComponent(edge); } // Assign an ordering id to this component. |