summaryrefslogtreecommitdiffstats
path: root/Source/cmMacroCommand.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2015-02-11 18:51:15 (GMT)
committerStephen Kelly <steveire@gmail.com>2015-02-11 21:58:33 (GMT)
commitf79c0f7697ee0bd25ec74f7dbb2ac0cf6189a9df (patch)
treea75ac3d5017af1030aa7fb0ae23e3587ddccf293 /Source/cmMacroCommand.cxx
parent8e0827b646b14028446503ac392a9ab7bb5a53a3 (diff)
downloadCMake-f79c0f7697ee0bd25ec74f7dbb2ac0cf6189a9df.zip
CMake-f79c0f7697ee0bd25ec74f7dbb2ac0cf6189a9df.tar.gz
CMake-f79c0f7697ee0bd25ec74f7dbb2ac0cf6189a9df.tar.bz2
cmMacroCommand: Compute variables outside of two loops.
Avoid computing them from scratch for each argument of each function.
Diffstat (limited to 'Source/cmMacroCommand.cxx')
-rw-r--r--Source/cmMacroCommand.cxx18
1 files changed, 12 insertions, 6 deletions
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 8bbb7c6..8424c75 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -115,6 +115,15 @@ bool cmMacroHelperCommand::InvokeInitialPass
= expandedArgs.begin() + (this->Args.size() - 1);
std::string expandedArgn = cmJoin(cmRange(eit, expandedArgs.end()), ";");
std::string expandedArgv = cmJoin(expandedArgs, ";");
+ std::vector<std::string> variables;
+ variables.reserve(this->Args.size() - 1);
+ for (unsigned int j = 1; j < this->Args.size(); ++j)
+ {
+ std::string variable = "${";
+ variable += this->Args[j];
+ variable += "}";
+ variables.push_back(variable);
+ }
if(!this->Functions.empty())
{
this->FilePath = this->Functions[0].FilePath;
@@ -147,13 +156,10 @@ bool cmMacroHelperCommand::InvokeInitialPass
{
tmps = k->Value;
// replace formal arguments
- for (unsigned int j = 1; j < this->Args.size(); ++j)
+ for (unsigned int j = 0; j < variables.size(); ++j)
{
- variable = "${";
- variable += this->Args[j];
- variable += "}";
- cmSystemTools::ReplaceString(tmps, variable.c_str(),
- expandedArgs[j-1].c_str());
+ cmSystemTools::ReplaceString(tmps, variables[j].c_str(),
+ expandedArgs[j].c_str());
}
// replace argc
cmSystemTools::ReplaceString(tmps, "${ARGC}",argcDef.c_str());