diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-02-15 14:48:51 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-02-15 19:47:51 (GMT) |
commit | 116459d34fab6327906e901753611636f84a16c1 (patch) | |
tree | ac4138eb8a7768db94db98988504f6b83b96b2c6 /Source/cmListCommand.cxx | |
parent | 1c7c35c3723abfb91f5e9a986ccd4f7e70683baf (diff) | |
download | CMake-116459d34fab6327906e901753611636f84a16c1.zip CMake-116459d34fab6327906e901753611636f84a16c1.tar.gz CMake-116459d34fab6327906e901753611636f84a16c1.tar.bz2 |
cmListCommand: Avoid needlessly erasing from vectors.
The entire vector will be destroyed at once at the end of the scope,
and the remove algorithms already give us the end of the range of
interesting values, so just use those sentinals.
Diffstat (limited to 'Source/cmListCommand.cxx')
-rw-r--r-- | Source/cmListCommand.cxx | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index e2ebe0a..98dcef1 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -357,13 +357,14 @@ bool cmListCommand std::vector<std::string> remove(args.begin() + 2, args.end()); std::sort(remove.begin(), remove.end()); - remove.erase(std::unique(remove.begin(), remove.end()), remove.end()); - - varArgsExpanded.erase( - cmRemoveMatching(varArgsExpanded, remove), - varArgsExpanded.end()); - - std::string value = cmJoin(varArgsExpanded, ";"); + std::vector<std::string>::const_iterator remEnd = + std::unique(remove.begin(), remove.end()); + std::vector<std::string>::const_iterator remBegin = remove.begin(); + + std::vector<std::string>::const_iterator argsEnd = + cmRemoveMatching(varArgsExpanded, cmRange(remBegin, remEnd)); + std::vector<std::string>::const_iterator argsBegin = varArgsExpanded.begin(); + std::string value = cmJoin(cmRange(argsBegin, argsEnd), ";"); this->Makefile->AddDefinition(listName, value.c_str()); return true; } @@ -418,9 +419,11 @@ bool cmListCommand return false; } - varArgsExpanded.erase(cmRemoveDuplicates(varArgsExpanded), - varArgsExpanded.end()); - std::string value = cmJoin(varArgsExpanded, ";"); + std::vector<std::string>::const_iterator argsEnd = + cmRemoveDuplicates(varArgsExpanded); + std::vector<std::string>::const_iterator argsBegin = + varArgsExpanded.begin(); + std::string value = cmJoin(cmRange(argsBegin, argsEnd), ";"); this->Makefile->AddDefinition(listName, value.c_str()); return true; @@ -503,13 +506,14 @@ bool cmListCommand::HandleRemoveAtCommand( } 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 = cmJoin(varArgsExpanded, ";"); - + std::vector<size_t>::const_iterator remEnd = + std::unique(removed.begin(), removed.end()); + std::vector<size_t>::const_iterator remBegin = removed.begin(); + + std::vector<std::string>::const_iterator argsEnd = + cmRemoveIndices(varArgsExpanded, cmRange(remBegin, remEnd)); + std::vector<std::string>::const_iterator argsBegin = varArgsExpanded.begin(); + std::string value = cmJoin(cmRange(argsBegin, argsEnd), ";"); this->Makefile->AddDefinition(listName, value.c_str()); return true; |