From e5ebeae768a8310b5cfdce0aeff9419e1de51eaa Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 11 Feb 2015 23:29:04 +0100 Subject: cmFunctionCommand: Split loop in two. --- Source/cmFunctionCommand.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index b44e228..a0a14e8 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -128,8 +128,6 @@ bool cmFunctionHelperCommand::InvokeInitialPass // define ARGV and ARGN std::vector::const_iterator eit; std::string argvDef; - std::string argnDef; - unsigned int cnt = 0; for ( eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit ) { if (!argvDef.empty()) @@ -137,6 +135,10 @@ bool cmFunctionHelperCommand::InvokeInitialPass argvDef += ";"; } argvDef += *eit; + } + std::string argnDef; + unsigned int cnt = 0; + for ( eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit ) if ( cnt >= this->Args.size()-1 ) { if (!argnDef.empty()) -- cgit v0.12 From fc1cf2654de04ed8f6954dc1907ab1dcb8bb946e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 11 Feb 2015 23:31:22 +0100 Subject: cmFunctionCommand: Remove counting variable. Start iteration at correct starting point directly. --- Source/cmFunctionCommand.cxx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index a0a14e8..088a697 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -137,17 +137,13 @@ bool cmFunctionHelperCommand::InvokeInitialPass argvDef += *eit; } std::string argnDef; - unsigned int cnt = 0; - for ( eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit ) - if ( cnt >= this->Args.size()-1 ) + eit = expandedArgs.begin() + (this->Args.size()-1); + for ( ; eit != expandedArgs.end(); ++eit) + if (!argnDef.empty()) { - if (!argnDef.empty()) - { - argnDef += ";"; - } - argnDef += *eit; + argnDef += ";"; } - cnt ++; + argnDef += *eit; } this->Makefile->AddDefinition("ARGV", argvDef.c_str()); this->Makefile->MarkVariableAsUsed("ARGV"); -- cgit v0.12 From 78757e7ffce9fb6297a2d501989e9b172e6151dc Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 11 Feb 2015 23:33:03 +0100 Subject: cmFunctionCommand: Replace loops with cmJoin. --- Source/cmFunctionCommand.cxx | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index 088a697..a4d9357 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -126,25 +126,10 @@ bool cmFunctionHelperCommand::InvokeInitialPass } // define ARGV and ARGN - std::vector::const_iterator eit; - std::string argvDef; - for ( eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit ) - { - if (!argvDef.empty()) - { - argvDef += ";"; - } - argvDef += *eit; - } - std::string argnDef; - eit = expandedArgs.begin() + (this->Args.size()-1); - for ( ; eit != expandedArgs.end(); ++eit) - if (!argnDef.empty()) - { - argnDef += ";"; - } - argnDef += *eit; - } + std::string argvDef = cmJoin(expandedArgs, ";"); + std::vector::const_iterator eit + = expandedArgs.begin() + (this->Args.size()-1); + std::string argnDef = cmJoin(cmRange(eit, expandedArgs.end()), ";"); this->Makefile->AddDefinition("ARGV", argvDef.c_str()); this->Makefile->MarkVariableAsUsed("ARGV"); this->Makefile->AddDefinition("ARGN", argnDef.c_str()); -- cgit v0.12