From 83414d5a07753d004f5e663c385ef0c713895d46 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 11 Feb 2015 20:16:40 +0100 Subject: [PATCH] cmMacroCommand: Move computation of ARGV%n names out of double loop. --- Source/cmMacroCommand.cxx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 44b14652c..49b9fd235 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -117,6 +117,14 @@ bool cmMacroHelperCommand::InvokeInitialPass { variables.push_back("${" + this->Args[j] + "}"); } + std::vector argVs; + argVs.reserve(expandedArgs.size()); + char argvName[60]; + for (unsigned int j = 0; j < expandedArgs.size(); ++j) + { + sprintf(argvName,"${ARGV%i}",j); + argVs.push_back(argvName); + } if(!this->Functions.empty()) { this->FilePath = this->Functions[0].FilePath; @@ -166,12 +174,9 @@ bool cmMacroHelperCommand::InvokeInitialPass // then try replacing ARGV values if (tmps.find("${ARGV") != std::string::npos) { - char argvName[60]; - // also replace the ARGV1 ARGV2 ... etc for (unsigned int t = 0; t < expandedArgs.size(); ++t) { - sprintf(argvName,"${ARGV%i}",t); - cmSystemTools::ReplaceString(tmps, argvName, + cmSystemTools::ReplaceString(tmps, argVs[t].c_str(), expandedArgs[t].c_str()); } }