summaryrefslogtreecommitdiffstats
path: root/Source/cmListCommand.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2015-02-15 14:23:43 (GMT)
committerStephen Kelly <steveire@gmail.com>2015-02-15 18:55:28 (GMT)
commit6a22e40147b7df5285a67b63249562ecbeff112e (patch)
treeab2e54e263a00c516cd5085710caab031ffa4ece /Source/cmListCommand.cxx
parent0b5cf0dabd430dfe1289e865b1b51c41066338a7 (diff)
downloadCMake-6a22e40147b7df5285a67b63249562ecbeff112e.zip
CMake-6a22e40147b7df5285a67b63249562ecbeff112e.tar.gz
CMake-6a22e40147b7df5285a67b63249562ecbeff112e.tar.bz2
cmListCommand: Use cmRemoveIndices for REMOVE_AT subcommand.
Avoid repeatedly looping over the indices to process elements (even without breaking out of the loop when the element is found).
Diffstat (limited to 'Source/cmListCommand.cxx')
-rw-r--r--Source/cmListCommand.cxx25
1 files changed, 9 insertions, 16 deletions
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index 826632f..93c6d66 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -527,26 +527,19 @@ bool cmListCommand::HandleRemoveAtCommand(
removed.push_back(static_cast<size_t>(item));
}
+ std::sort(removed.begin(), removed.end());
+ removed.erase(std::unique(removed.begin(), removed.end()), removed.end());
+
+ varArgsExpanded.erase(cmRemoveIndices(varArgsExpanded, removed),
+ varArgsExpanded.end());
+
std::string value;
const char* sep = "";
for ( cc = 0; cc < varArgsExpanded.size(); ++ cc )
{
- size_t kk;
- bool found = false;
- for ( kk = 0; kk < removed.size(); ++ kk )
- {
- if ( cc == removed[kk] )
- {
- found = true;
- }
- }
-
- if ( !found )
- {
- value += sep;
- value += varArgsExpanded[cc];
- sep = ";";
- }
+ value += sep;
+ value += varArgsExpanded[cc];
+ sep = ";";
}
this->Makefile->AddDefinition(listName, value.c_str());