summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-03-12 19:26:33 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-03-12 19:26:33 (GMT)
commit153e2dc3fc73fdb778e56e238441aab2a9f673dc (patch)
treed13411e5e1dc49ec2d98e4eff1647b097b4ccd4a /Source
parentdfeeda3778e4b436add8ad95a1c9daab52309901 (diff)
parent3ff95f3b0b1eed95aa6e4d6baa59c68a047072ea (diff)
downloadCMake-153e2dc3fc73fdb778e56e238441aab2a9f673dc.zip
CMake-153e2dc3fc73fdb778e56e238441aab2a9f673dc.tar.gz
CMake-153e2dc3fc73fdb778e56e238441aab2a9f673dc.tar.bz2
Merge topic 'cmAlgorithms-early-return'
3ff95f3b cmAlgorithms: Add early return in cmRemoveIndices.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmAlgorithms.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index b9d7e78..be57da3 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -237,6 +237,11 @@ typename Range::const_iterator cmRemoveIndices(Range& r, InputRange const& rem)
{
typename InputRange::const_iterator remIt = rem.begin();
typename InputRange::const_iterator remEnd = rem.end();
+ const typename Range::iterator rangeEnd = r.end();
+ if (remIt == remEnd)
+ {
+ return rangeEnd;
+ }
typename Range::iterator writer = r.begin();
std::advance(writer, *remIt);
@@ -244,7 +249,6 @@ typename Range::const_iterator cmRemoveIndices(Range& r, InputRange const& rem)
typename InputRange::value_type prevRem = *remIt;
++remIt;
size_t count = 1;
- const typename Range::iterator rangeEnd = r.end();
for ( ; writer != rangeEnd && remIt != remEnd; ++count, ++remIt)
{
std::advance(pivot, *remIt - prevRem);