[Cmake-commits] CMake branch, next, updated. v3.1.2-1322-g015e5e0

Stephen Kelly steveire at gmail.com
Wed Feb 11 16:59:17 EST 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  015e5e0c2cd0573f1ca07103216530703c337eb1 (commit)
       via  b5f98e5012ef53ee6746c42131fc66892bfff717 (commit)
       via  83414d5a07753d004f5e663c385ef0c713895d46 (commit)
       via  9a1f8f35f48d7dcfefc70de9ae530c31b16cd9e0 (commit)
       via  4aa7bd2ac11aa2edb0288e5ba360984b7799130d (commit)
       via  6774c92b5809b80c767ef8094b2f26d06556e0fd (commit)
       via  2c4a7298fcb3ac6a6b6c0a9545b343c814f3d6ec (commit)
       via  a551851ab3f23f58074638ffcf38a08d98a35fa8 (commit)
       via  f79c0f7697ee0bd25ec74f7dbb2ac0cf6189a9df (commit)
       via  8e0827b646b14028446503ac392a9ab7bb5a53a3 (commit)
       via  f2c49f59d8dbca936a40b62a9079fa71ca551365 (commit)
       via  3250a7e535684bec684c0109b31675ba72dc3aa9 (commit)
       via  081a13f7c011d0ebd28caebfedee1e3e3f7602c9 (commit)
       via  17b5ebd383df4c0c731b5c687ccaa3608b2d188f (commit)
       via  7c3f637680ac0cdb6cec5e75ba4a9b188de5017b (commit)
       via  8a399c8c9f1c4a793289d6baf37081efac082eee (commit)
       via  abfca97525be06e067981b6c6bf63ba7a3aa52f9 (commit)
       via  0b61b86df856e3cec366f8c23f35aae576b2d821 (commit)
       via  e21f7829a2891ce7599ade02d4fd9c193657069a (commit)
       via  559dc15589ad0b9a7bdaa62ac7552899993f6f0d (commit)
       via  0ea719326ea78b423a5ec95b1218b626e9392f07 (commit)
       via  9380e85f865e29cd5968e91408a31d5160f4a4cb (commit)
       via  bb10012fea677fd8aa1bbefd06061efcb7ec1955 (commit)
       via  0c12f1ea0da0a5822a7a69b4ff77b45732c72466 (commit)
       via  27c6f017a1ef7c62f7f0332d624add7e8189f81c (commit)
       via  4e78ebbdf94b99f7b7d5b9b31d05dd9479b1d6ab (commit)
       via  8910224950a2b723e0d4fd7c21a326af7fb2e050 (commit)
       via  7b8725bf8472ebf4781ddd60ef8fcca9c3ad98dd (commit)
       via  7ee56f03999e8605cc2cbe85a3a7b7159e639e5d (commit)
       via  0a4e5674eccb0126733086d4632c7239217db6f1 (commit)
      from  e610103fe20600300893e78426ade8c645ee87bb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=015e5e0c2cd0573f1ca07103216530703c337eb1
commit 015e5e0c2cd0573f1ca07103216530703c337eb1
Merge: e610103 b5f98e5
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Feb 11 16:59:15 2015 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Feb 11 16:59:15 2015 -0500

    Merge topic 'clean-up-cmMacroCommand' into next
    
    b5f98e50 cmMacroCommand: Manipulate target string directly.
    83414d5a cmMacroCommand: Move computation of ARGV%n names out of double loop.
    9a1f8f35 cmMacroCommand: Move ARGV replacement out of condition.
    4aa7bd2a cmMacroCommand: Remove condition around ARGN replacement.
    6774c92b cmMacroCommand: Declare tmps in the scope that it's used.
    2c4a7298 cmMacroCommand: Declare arg in the scope that it is used.
    a551851a cmMacroCommand: Inline variable computation.
    f79c0f76 cmMacroCommand: Compute variables outside of two loops.
    8e0827b6 cmMacroCommand: Remove intermediate arg variables.
    f2c49f59 cmMacroCommand: Remove condition around ARGN computation.
    3250a7e5 cmMacroCommand: Remove conditional append of semicolon.
    081a13f7 cmMacroCommand: Declare arg variables where used and initialized.
    17b5ebd3 cmMacroCommand: Join the args strings outside of the loops.
    7c3f6376 Convert loop into two algorithms.
    8a399c8c Convert loop to the common pattern.
    abfca975 Move loop inside of condition.
    ...


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b5f98e5012ef53ee6746c42131fc66892bfff717
commit b5f98e5012ef53ee6746c42131fc66892bfff717
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Feb 11 22:16:03 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:34 2015 +0100

    cmMacroCommand: Manipulate target string directly.
    
    Avoid copying a string from the source, manipulating it, and then
    copying it back.  Manipulate it in place instead.

diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 49b9fd2..29e8cb1 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -151,37 +151,33 @@ bool cmMacroHelperCommand::InvokeInitialPass
       k->FilePath = this->FilePath.c_str();
 
       cmListFileArgument arg;
-      if(k->Delim == cmListFileArgument::Bracket)
+      arg.Value = k->Value;
+      if(k->Delim != cmListFileArgument::Bracket)
         {
-        arg.Value = k->Value;
-        }
-      else
-        {
-        std::string tmps = k->Value;
         // replace formal arguments
         for (unsigned int j = 0; j < variables.size(); ++j)
           {
-          cmSystemTools::ReplaceString(tmps, variables[j].c_str(),
+          cmSystemTools::ReplaceString(arg.Value, variables[j].c_str(),
                                        expandedArgs[j].c_str());
           }
         // replace argc
-        cmSystemTools::ReplaceString(tmps, "${ARGC}",argcDef.c_str());
+        cmSystemTools::ReplaceString(arg.Value, "${ARGC}",argcDef.c_str());
 
-        cmSystemTools::ReplaceString(tmps, "${ARGN}", expandedArgn.c_str());
-        cmSystemTools::ReplaceString(tmps, "${ARGV}", expandedArgv.c_str());
+        cmSystemTools::ReplaceString(arg.Value, "${ARGN}",
+                                     expandedArgn.c_str());
+        cmSystemTools::ReplaceString(arg.Value, "${ARGV}",
+                                     expandedArgv.c_str());
 
         // if the current argument of the current function has ${ARGV in it
         // then try replacing ARGV values
-        if (tmps.find("${ARGV") != std::string::npos)
+        if (arg.Value.find("${ARGV") != std::string::npos)
           {
           for (unsigned int t = 0; t < expandedArgs.size(); ++t)
             {
-            cmSystemTools::ReplaceString(tmps, argVs[t].c_str(),
+            cmSystemTools::ReplaceString(arg.Value, argVs[t].c_str(),
                                          expandedArgs[t].c_str());
             }
           }
-
-        arg.Value = tmps;
         }
       arg.Delim = k->Delim;
       arg.FilePath = k->FilePath;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=83414d5a07753d004f5e663c385ef0c713895d46
commit 83414d5a07753d004f5e663c385ef0c713895d46
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Feb 11 20:16:40 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:34 2015 +0100

    cmMacroCommand: Move computation of ARGV%n names out of double loop.

diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 44b1465..49b9fd2 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -117,6 +117,14 @@ bool cmMacroHelperCommand::InvokeInitialPass
     {
     variables.push_back("${" + this->Args[j] + "}");
     }
+  std::vector<std::string> 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());
             }
           }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9a1f8f35f48d7dcfefc70de9ae530c31b16cd9e0
commit 9a1f8f35f48d7dcfefc70de9ae530c31b16cd9e0
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Feb 11 20:08:05 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:34 2015 +0100

    cmMacroCommand: Move ARGV replacement out of condition.

diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 111ad96..44b1465 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -160,14 +160,13 @@ bool cmMacroHelperCommand::InvokeInitialPass
         cmSystemTools::ReplaceString(tmps, "${ARGC}",argcDef.c_str());
 
         cmSystemTools::ReplaceString(tmps, "${ARGN}", expandedArgn.c_str());
+        cmSystemTools::ReplaceString(tmps, "${ARGV}", expandedArgv.c_str());
 
         // if the current argument of the current function has ${ARGV in it
         // then try replacing ARGV values
         if (tmps.find("${ARGV") != std::string::npos)
           {
           char argvName[60];
-          cmSystemTools::ReplaceString(tmps, "${ARGV}", expandedArgv.c_str());
-
           // also replace the ARGV1 ARGV2 ... etc
           for (unsigned int t = 0; t < expandedArgs.size(); ++t)
             {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4aa7bd2ac11aa2edb0288e5ba360984b7799130d
commit 4aa7bd2ac11aa2edb0288e5ba360984b7799130d
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Feb 11 20:06:39 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:34 2015 +0100

    cmMacroCommand: Remove condition around ARGN replacement.
    
    There is none for ARGC replacement, so no reason to conditionalize the
    replacement.  The computation is already done.

diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 6635fee..111ad96 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -159,11 +159,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
         // replace argc
         cmSystemTools::ReplaceString(tmps, "${ARGC}",argcDef.c_str());
 
-        // repleace ARGN
-        if (tmps.find("${ARGN}") != std::string::npos)
-          {
-          cmSystemTools::ReplaceString(tmps, "${ARGN}", expandedArgn.c_str());
-          }
+        cmSystemTools::ReplaceString(tmps, "${ARGN}", expandedArgn.c_str());
 
         // if the current argument of the current function has ${ARGV in it
         // then try replacing ARGV values

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6774c92b5809b80c767ef8094b2f26d06556e0fd
commit 6774c92b5809b80c767ef8094b2f26d06556e0fd
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Feb 11 20:25:44 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:34 2015 +0100

    cmMacroCommand: Declare tmps in the scope that it's used.
    
    We don't particularly need to reuse the string memory here, and this
    pattern is not common in CMake.

diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index bd53b1e..6635fee 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -84,8 +84,6 @@ bool cmMacroHelperCommand::InvokeInitialPass
   std::vector<std::string> expandedArgs;
   this->Makefile->ExpandArguments(args, expandedArgs);
 
-  std::string tmps;
-
   // make sure the number of arguments passed is at least the number
   // required by the signature
   if (expandedArgs.size() < this->Args.size() - 1)
@@ -151,7 +149,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
         }
       else
         {
-        tmps = k->Value;
+        std::string tmps = k->Value;
         // replace formal arguments
         for (unsigned int j = 0; j < variables.size(); ++j)
           {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2c4a7298fcb3ac6a6b6c0a9545b343c814f3d6ec
commit 2c4a7298fcb3ac6a6b6c0a9545b343c814f3d6ec
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Feb 11 20:23:36 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:34 2015 +0100

    cmMacroCommand: Declare arg in the scope that it is used.
    
    It can make sense to declare objects outside of loops if
    the size required by the object can grow (eg std::string when
    using getline), but that is not the case here.

diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 6f45484..bd53b1e 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -85,7 +85,6 @@ bool cmMacroHelperCommand::InvokeInitialPass
   this->Makefile->ExpandArguments(args, expandedArgs);
 
   std::string tmps;
-  cmListFileArgument arg;
 
   // make sure the number of arguments passed is at least the number
   // required by the signature
@@ -144,6 +143,8 @@ bool cmMacroHelperCommand::InvokeInitialPass
       // Set the FilePath on the arguments to match the function since it is
       // not stored and the original values may be freed
       k->FilePath = this->FilePath.c_str();
+
+      cmListFileArgument arg;
       if(k->Delim == cmListFileArgument::Bracket)
         {
         arg.Value = k->Value;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a551851ab3f23f58074638ffcf38a08d98a35fa8
commit a551851ab3f23f58074638ffcf38a08d98a35fa8
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Feb 11 20:14:30 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:33 2015 +0100

    cmMacroCommand: Inline variable computation.

diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 8424c75..6f45484 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -86,7 +86,6 @@ bool cmMacroHelperCommand::InvokeInitialPass
 
   std::string tmps;
   cmListFileArgument arg;
-  std::string variable;
 
   // make sure the number of arguments passed is at least the number
   // required by the signature
@@ -119,10 +118,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
   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);
+    variables.push_back("${" + this->Args[j] + "}");
     }
   if(!this->Functions.empty())
     {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f79c0f7697ee0bd25ec74f7dbb2ac0cf6189a9df
commit f79c0f7697ee0bd25ec74f7dbb2ac0cf6189a9df
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Feb 11 19:51:15 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:33 2015 +0100

    cmMacroCommand: Compute variables outside of two loops.
    
    Avoid computing them from scratch for each argument of each
    function.

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());

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8e0827b646b14028446503ac392a9ab7bb5a53a3
commit 8e0827b646b14028446503ac392a9ab7bb5a53a3
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Feb 11 19:26:33 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:33 2015 +0100

    cmMacroCommand: Remove intermediate arg variables.

diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 9fc479e..8bbb7c6 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -161,9 +161,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
         // repleace ARGN
         if (tmps.find("${ARGN}") != std::string::npos)
           {
-          std::string argnDef;
-          argnDef += expandedArgn;
-          cmSystemTools::ReplaceString(tmps, "${ARGN}", argnDef.c_str());
+          cmSystemTools::ReplaceString(tmps, "${ARGN}", expandedArgn.c_str());
           }
 
         // if the current argument of the current function has ${ARGV in it
@@ -171,10 +169,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
         if (tmps.find("${ARGV") != std::string::npos)
           {
           char argvName[60];
-
-          std::string argvDef;
-          argvDef += expandedArgv;
-          cmSystemTools::ReplaceString(tmps, "${ARGV}", argvDef.c_str());
+          cmSystemTools::ReplaceString(tmps, "${ARGV}", expandedArgv.c_str());
 
           // also replace the ARGV1 ARGV2 ... etc
           for (unsigned int t = 0; t < expandedArgs.size(); ++t)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f2c49f59d8dbca936a40b62a9079fa71ca551365
commit f2c49f59d8dbca936a40b62a9079fa71ca551365
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Feb 11 19:17:29 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:33 2015 +0100

    cmMacroCommand: Remove condition around ARGN computation.
    
    An empty string is appended if the condition is false, which is
    ok for this commit.

diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index b27b994..9fc479e 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -162,10 +162,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
         if (tmps.find("${ARGN}") != std::string::npos)
           {
           std::string argnDef;
-          if (expandedArgs.size() > this->Args.size() - 1)
-            {
-            argnDef += expandedArgn;
-            }
+          argnDef += expandedArgn;
           cmSystemTools::ReplaceString(tmps, "${ARGN}", argnDef.c_str());
           }
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3250a7e535684bec684c0109b31675ba72dc3aa9
commit 3250a7e535684bec684c0109b31675ba72dc3aa9
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Feb 11 19:16:15 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:33 2015 +0100

    cmMacroCommand: Remove conditional append of semicolon.
    
    The conditions are never true.

diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index f7daa76..b27b994 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -164,10 +164,6 @@ bool cmMacroHelperCommand::InvokeInitialPass
           std::string argnDef;
           if (expandedArgs.size() > this->Args.size() - 1)
             {
-            if (!argnDef.empty() && !expandedArgs.empty())
-              {
-              argnDef += ";";
-              }
             argnDef += expandedArgn;
             }
           cmSystemTools::ReplaceString(tmps, "${ARGN}", argnDef.c_str());
@@ -180,10 +176,6 @@ bool cmMacroHelperCommand::InvokeInitialPass
           char argvName[60];
 
           std::string argvDef;
-          if (!argvDef.empty() && !expandedArgs.empty())
-            {
-            argvDef += ";";
-            }
           argvDef += expandedArgv;
           cmSystemTools::ReplaceString(tmps, "${ARGV}", argvDef.c_str());
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=081a13f7c011d0ebd28caebfedee1e3e3f7602c9
commit 081a13f7c011d0ebd28caebfedee1e3e3f7602c9
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Feb 11 19:10:19 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:33 2015 +0100

    cmMacroCommand: Declare arg variables where used and initialized.
    
    Make the initialization by population with the expanded* content
    unconditional.

diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index de52fc9..f7daa76 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -111,15 +111,10 @@ bool cmMacroHelperCommand::InvokeInitialPass
   argcDefStream << expandedArgs.size();
   std::string argcDef = argcDefStream.str();
 
-  // declare varuiables for ARGV ARGN but do not compute until needed
-  std::string argvDef;
-  std::string argnDef;
   std::vector<std::string>::const_iterator eit
       = expandedArgs.begin() + (this->Args.size() - 1);
   std::string expandedArgn = cmJoin(cmRange(eit, expandedArgs.end()), ";");
   std::string expandedArgv = cmJoin(expandedArgs, ";");
-  bool argnDefInitialized = false;
-  bool argvDefInitialized = false;
   if(!this->Functions.empty())
     {
     this->FilePath = this->Functions[0].FilePath;
@@ -166,17 +161,14 @@ bool cmMacroHelperCommand::InvokeInitialPass
         // repleace ARGN
         if (tmps.find("${ARGN}") != std::string::npos)
           {
-          if (!argnDefInitialized)
+          std::string argnDef;
+          if (expandedArgs.size() > this->Args.size() - 1)
             {
-            if (expandedArgs.size() > this->Args.size() - 1)
+            if (!argnDef.empty() && !expandedArgs.empty())
               {
-              if (!argnDef.empty() && !expandedArgs.empty())
-                {
-                argnDef += ";";
-                }
-              argnDef += expandedArgn;
+              argnDef += ";";
               }
-            argnDefInitialized = true;
+            argnDef += expandedArgn;
             }
           cmSystemTools::ReplaceString(tmps, "${ARGN}", argnDef.c_str());
           }
@@ -187,16 +179,12 @@ bool cmMacroHelperCommand::InvokeInitialPass
           {
           char argvName[60];
 
-          // repleace ARGV, compute it only once
-          if (!argvDefInitialized)
+          std::string argvDef;
+          if (!argvDef.empty() && !expandedArgs.empty())
             {
-            if (!argvDef.empty() && !expandedArgs.empty())
-              {
-              argvDef += ";";
-              }
-            argvDef += expandedArgv;
-            argvDefInitialized = true;
+            argvDef += ";";
             }
+          argvDef += expandedArgv;
           cmSystemTools::ReplaceString(tmps, "${ARGV}", argvDef.c_str());
 
           // also replace the ARGV1 ARGV2 ... etc

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=17b5ebd383df4c0c731b5c687ccaa3608b2d188f
commit 17b5ebd383df4c0c731b5c687ccaa3608b2d188f
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Feb 11 20:47:16 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:31 2015 +0100

    cmMacroCommand: Join the args strings outside of the loops.
    
    This means that we compute the strings even if not used in the macro
    but this shouldn't be expensive and it simplifies the code.

diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 8f6364d..de52fc9 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -114,6 +114,10 @@ bool cmMacroHelperCommand::InvokeInitialPass
   // declare varuiables for ARGV ARGN but do not compute until needed
   std::string argvDef;
   std::string argnDef;
+  std::vector<std::string>::const_iterator eit
+      = expandedArgs.begin() + (this->Args.size() - 1);
+  std::string expandedArgn = cmJoin(cmRange(eit, expandedArgs.end()), ";");
+  std::string expandedArgv = cmJoin(expandedArgs, ";");
   bool argnDefInitialized = false;
   bool argvDefInitialized = false;
   if(!this->Functions.empty())
@@ -170,9 +174,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
                 {
                 argnDef += ";";
                 }
-              std::vector<std::string>::const_iterator eit
-                  = expandedArgs.begin() + (this->Args.size() - 1);
-              argnDef += cmJoin(cmRange(eit, expandedArgs.end()), ";");
+              argnDef += expandedArgn;
               }
             argnDefInitialized = true;
             }
@@ -192,7 +194,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
               {
               argvDef += ";";
               }
-            argvDef += cmJoin(expandedArgs, ";");
+            argvDef += expandedArgv;
             argvDefInitialized = true;
             }
           cmSystemTools::ReplaceString(tmps, "${ARGV}", argvDef.c_str());

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7c3f637680ac0cdb6cec5e75ba4a9b188de5017b
commit 7c3f637680ac0cdb6cec5e75ba4a9b188de5017b
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Jan 24 18:07:37 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:09 2015 +0100

    Convert loop into two algorithms.

diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 359141a..a08c159 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -2299,16 +2299,12 @@ cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p,
       {
       // Now add the rest of the components separated by the proper slash
       // direction for this platform.
-      const char* sep = "";
-      for(unsigned int i=1; i < components.size() - 1; ++i)
-        {
-        if(!components[i].empty())
-          {
-          result += sep;
-          result += components[i];
-          sep = slash;
-          }
-        }
+      std::vector<std::string>::const_iterator compEnd
+          = std::remove(components.begin() + 1, components.end() - 1,
+                          std::string());
+      std::vector<std::string>::const_iterator compStart
+          = components.begin() + 1;
+      result += cmJoin(cmRange(compStart, compEnd), slash);
       // Only the last component can be empty to avoid double slashes.
       result += slash;
       result += components.back();

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8a399c8c9f1c4a793289d6baf37081efac082eee
commit 8a399c8c9f1c4a793289d6baf37081efac082eee
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Jan 23 01:06:40 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:09 2015 +0100

    Convert loop to the common pattern.

diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 703ab27..359141a 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -2299,24 +2299,18 @@ cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p,
       {
       // Now add the rest of the components separated by the proper slash
       // direction for this platform.
-      bool first = true;
+      const char* sep = "";
       for(unsigned int i=1; i < components.size() - 1; ++i)
         {
         if(!components[i].empty())
           {
-          if(!first)
-            {
-            result += slash;
-            }
+          result += sep;
           result += components[i];
-          first = false;
+          sep = slash;
           }
         }
       // Only the last component can be empty to avoid double slashes.
-      if(!first)
-        {
-        result += slash;
-        }
+      result += slash;
       result += components.back();
       }
     }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=abfca97525be06e067981b6c6bf63ba7a3aa52f9
commit abfca97525be06e067981b6c6bf63ba7a3aa52f9
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Feb 10 23:09:03 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:09 2015 +0100

    Move loop inside of condition.
    
    The loop is only executed if the condition is true.

diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 32da821..703ab27 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -2295,23 +2295,23 @@ cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p,
     // Begin the quoted result with the root component.
     result += components[0];
 
-    // Now add the rest of the components separated by the proper slash
-    // direction for this platform.
-    bool first = true;
-    for(unsigned int i=1; i < components.size() - 1; ++i)
+    if (components.size() > 1)
       {
-      if(!components[i].empty())
+      // Now add the rest of the components separated by the proper slash
+      // direction for this platform.
+      bool first = true;
+      for(unsigned int i=1; i < components.size() - 1; ++i)
         {
-        if(!first)
+        if(!components[i].empty())
           {
-          result += slash;
+          if(!first)
+            {
+            result += slash;
+            }
+          result += components[i];
+          first = false;
           }
-        result += components[i];
-        first = false;
         }
-      }
-    if (components.size() > 1)
-      {
       // Only the last component can be empty to avoid double slashes.
       if(!first)
         {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0b61b86df856e3cec366f8c23f35aae576b2d821
commit 0b61b86df856e3cec366f8c23f35aae576b2d821
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Jan 23 01:03:45 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:08 2015 +0100

    Handle last element outside of the loop.
    
    There is no point in checking on each loop iteration whether
    it is the last element.

diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 54d330f..32da821 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -2298,10 +2298,9 @@ cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p,
     // Now add the rest of the components separated by the proper slash
     // direction for this platform.
     bool first = true;
-    for(unsigned int i=1; i < components.size(); ++i)
+    for(unsigned int i=1; i < components.size() - 1; ++i)
       {
-      // Only the last component can be empty to avoid double slashes.
-      if(!components[i].empty() || (i == (components.size()-1)))
+      if(!components[i].empty())
         {
         if(!first)
           {
@@ -2311,6 +2310,15 @@ cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p,
         first = false;
         }
       }
+    if (components.size() > 1)
+      {
+      // Only the last component can be empty to avoid double slashes.
+      if(!first)
+        {
+        result += slash;
+        }
+      result += components.back();
+      }
     }
 
   // Close the quoted result.

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e21f7829a2891ce7599ade02d4fd9c193657069a
commit e21f7829a2891ce7599ade02d4fd9c193657069a
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Feb 10 22:48:02 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:08 2015 +0100

    cmTarget: Use a sorted vector in place of a set.
    
    The vector has a more easy-to-use API.
    
    Join the string with cmJoin, and avoid erasing from the container
    in the loop.

diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index f0bdea7..526a923 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -6687,40 +6687,33 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info,
 
   if (!prop.empty())
     {
-    // Use a std::set to keep the error message sorted.
-    std::set<std::string> props;
+    // Use a sorted std::vector to keep the error message sorted.
+    std::vector<std::string> props;
     std::set<std::string>::const_iterator i = emittedBools.find(prop);
     if (i != emittedBools.end())
       {
-      props.insert(strBool);
+      props.push_back(strBool);
       }
     i = emittedStrings.find(prop);
     if (i != emittedStrings.end())
       {
-      props.insert(strString);
+      props.push_back(strString);
       }
     i = emittedMinNumbers.find(prop);
     if (i != emittedMinNumbers.end())
       {
-      props.insert(strNumMin);
+      props.push_back(strNumMin);
       }
     i = emittedMaxNumbers.find(prop);
     if (i != emittedMaxNumbers.end())
       {
-      props.insert(strNumMax);
+      props.push_back(strNumMax);
       }
+    std::sort(props.begin(), props.end());
+
+    std::string propsString = cmJoin(cmRange(props).retreat(1), ", ");
+    propsString += " and the " + props.back();
 
-    std::string propsString = *props.begin();
-    props.erase(props.begin());
-    while (props.size() > 1)
-      {
-      propsString += ", " + *props.begin();
-      props.erase(props.begin());
-      }
-   if (props.size() == 1)
-     {
-     propsString += " and the " + *props.begin();
-     }
     std::ostringstream e;
     e << "Property \"" << prop << "\" appears in both the "
       << propsString <<

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=559dc15589ad0b9a7bdaa62ac7552899993f6f0d
commit 559dc15589ad0b9a7bdaa62ac7552899993f6f0d
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Feb 10 23:26:58 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:08 2015 +0100

    cmSet: Replace loop with cmJoin.

diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx
index 90d7b03..204d95b 100644
--- a/Source/cmSetCommand.cxx
+++ b/Source/cmSetCommand.cxx
@@ -108,17 +108,7 @@ bool cmSetCommand
     }
 
   // collect any values into a single semi-colon separated value list
-  if(static_cast<unsigned short>(args.size()) >
-     static_cast<unsigned short>(1 + ignoreLastArgs))
-    {
-    value = args[1];
-    size_t endPos = args.size() - ignoreLastArgs;
-    for(size_t i = 2; i < endPos; ++i)
-      {
-      value += ";";
-      value += args[i];
-      }
-    }
+  value = cmJoin(cmRange(args).advance(1).retreat(ignoreLastArgs), ";");
 
   if (parentScope)
     {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0ea719326ea78b423a5ec95b1218b626e9392f07
commit 0ea719326ea78b423a5ec95b1218b626e9392f07
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Jan 14 22:23:41 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:08 2015 +0100

    cmFindBase: Replace loop with cmJoin on range.

diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index 69991d5..6e55533 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -166,11 +166,9 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
       }
     else
       {
-      this->VariableDocumentation += "one of the " + this->Names[0];
-      for (unsigned int j = 1; j < this->Names.size() - 1; ++j)
-        {
-        this->VariableDocumentation += ", " + this->Names[j];
-        }
+      this->VariableDocumentation += "one of the ";
+      this->VariableDocumentation += cmJoin(cmRange(this->Names).retreat(1),
+                                            ", ");
       this->VariableDocumentation += " or "
         + this->Names[this->Names.size() - 1] + " libraries be found";
       }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9380e85f865e29cd5968e91408a31d5160f4a4cb
commit 9380e85f865e29cd5968e91408a31d5160f4a4cb
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jan 25 15:53:20 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:58:04 2015 +0100

    Convert loops to cmJoin algorithm with cmRange.

diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index 8d1657d..dd0cfa9 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -259,14 +259,7 @@ bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args)
     {
     listString += ";";
     }
-  const char* sep = "";
-  size_t cc;
-  for ( cc = 2; cc < args.size(); ++ cc )
-    {
-    listString += sep;
-    listString += args[cc];
-    sep = ";";
-    }
+  listString += cmJoin(cmRange(args).advance(2), ";");
 
   this->Makefile->AddDefinition(listName, listString.c_str());
   return true;
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 05d8ab5..35956ad 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -3016,13 +3016,7 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
     {
     relative += "/";
     }
-  const char* sep = "";
-  for(unsigned int i=common; i < remote.size(); ++i)
-    {
-    relative += sep;
-    relative += remote[i];
-    sep = "/";
-    }
+  relative += cmJoin(cmRange(remote).advance(common), "/");
 
   // Finally return the path.
   return relative;
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 676e082..8f6364d 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -172,12 +172,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
                 }
               std::vector<std::string>::const_iterator eit
                   = expandedArgs.begin() + (this->Args.size() - 1);
-              const char* sep = "";
-              for( ; eit != expandedArgs.end(); ++eit)
-                {
-                argnDef += sep + *eit;
-                sep = ";";
-                }
+              argnDef += cmJoin(cmRange(eit, expandedArgs.end()), ";");
               }
             argnDefInitialized = true;
             }
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 5260cb0..5c93975 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -406,12 +406,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
     // Clock command
     else if (args[1] == "time" && args.size() > 2)
       {
-      std::string command = args[2];
-      for (std::string::size_type cc = 3; cc < args.size(); cc ++)
-        {
-        command += " ";
-        command += args[cc];
-        }
+      std::string command = cmJoin(cmRange(args).advance(2), " ");
 
       clock_t clock_start, clock_finish;
       time_t time_start, time_finish;
@@ -473,14 +468,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
         }
 
       std::string command = "\"";
-      command += args[3];
+      command += cmJoin(cmRange(args).advance(3), "\" \"");
       command += "\"";
-      for (std::string::size_type cc = 4; cc < args.size(); cc ++)
-        {
-        command += " \"";
-        command += args[cc];
-        command += "\"";
-        }
       int retval = 0;
       int timeout = 0;
       if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, &retval,

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bb10012fea677fd8aa1bbefd06061efcb7ec1955
commit bb10012fea677fd8aa1bbefd06061efcb7ec1955
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Feb 10 22:23:41 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:57:56 2015 +0100

    cmStringCommand: Accumulate with cmJoin and range adaptors.

diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 3e606d7..edc6afc 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -303,13 +303,6 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
   std::string regex = args[2];
   std::string outvar = args[3];
 
-  // Concatenate all the last arguments together.
-  std::string input = args[4];
-  for(unsigned int i=5; i < args.size(); ++i)
-    {
-    input += args[i];
-    }
-
   this->Makefile->ClearMatches();
   // Compile the regular expression.
   cmsys::RegularExpression re;
@@ -321,6 +314,9 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
     return false;
     }
 
+  // Concatenate all the last arguments together.
+  std::string input = cmJoin(cmRange(args).advance(4), std::string());
+
   // Scan through the input for all matches.
   std::string output;
   if(re.find(input.c_str()))
@@ -352,13 +348,6 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
   std::string regex = args[2];
   std::string outvar = args[3];
 
-  // Concatenate all the last arguments together.
-  std::string input = args[4];
-  for(unsigned int i=5; i < args.size(); ++i)
-    {
-    input += args[i];
-    }
-
   this->Makefile->ClearMatches();
   // Compile the regular expression.
   cmsys::RegularExpression re;
@@ -371,6 +360,9 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
     return false;
     }
 
+  // Concatenate all the last arguments together.
+  std::string input = cmJoin(cmRange(args).advance(4), std::string());
+
   // Scan through the input for all matches.
   std::string output;
   const char* p = input.c_str();
@@ -456,13 +448,6 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
     l = r;
     }
 
-  // Concatenate all the last arguments together.
-  std::string input = args[5];
-  for(unsigned int i=6; i < args.size(); ++i)
-    {
-    input += args[i];
-    }
-
   this->Makefile->ClearMatches();
   // Compile the regular expression.
   cmsys::RegularExpression re;
@@ -475,6 +460,9 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
     return false;
     }
 
+  // Concatenate all the last arguments together.
+  std::string input = cmJoin(cmRange(args).advance(5), std::string());
+
   // Scan through the input for all matches.
   std::string output;
   std::string::size_type base = 0;
@@ -673,11 +661,7 @@ bool cmStringCommand::HandleReplaceCommand(std::vector<std::string> const&
   const std::string& replaceExpression = args[2];
   const std::string& variableName = args[3];
 
-  std::string input = args[4];
-  for(unsigned int i=5; i < args.size(); ++i)
-    {
-    input += args[i];
-    }
+  std::string input = cmJoin(cmRange(args).advance(4), std::string());
 
   cmsys::SystemTools::ReplaceString(input, matchExpression.c_str(),
                                     replaceExpression.c_str());
@@ -756,11 +740,7 @@ bool cmStringCommand
     }
 
   std::string const& variableName = args[1];
-  std::string value;
-  for(unsigned int i = 2; i < args.size(); ++i)
-    {
-    value += args[i];
-    }
+  std::string value = cmJoin(cmRange(args).advance(2), std::string());
 
   this->Makefile->AddDefinition(variableName, value.c_str());
   return true;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0c12f1ea0da0a5822a7a69b4ff77b45732c72466
commit 0c12f1ea0da0a5822a7a69b4ff77b45732c72466
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Feb 10 22:14:54 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:57:55 2015 +0100

    cmAlgorithms: Add a range adaptor and API for adjusting a range.

diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index 6c03f51..ad2b9c1 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -122,6 +122,17 @@ struct Range
   const_iterator begin() const { return Begin; }
   const_iterator end() const { return End; }
   bool empty() const { return std::distance(Begin, End) == 0; }
+  Range& advance(cmIML_INT_intptr_t amount)
+  {
+    std::advance(Begin, amount);
+    return *this;
+  }
+
+  Range& retreat(cmIML_INT_intptr_t amount)
+  {
+    std::advance(End, -amount);
+    return *this;
+  }
 private:
   const_iterator Begin;
   const_iterator End;
@@ -135,6 +146,14 @@ ContainerAlgorithms::Range<Iter1> cmRange(Iter1 begin, Iter2 end)
   return ContainerAlgorithms::Range<Iter1>(begin, end);
 }
 
+template<typename Range>
+ContainerAlgorithms::Range<typename Range::const_iterator>
+cmRange(Range const& range)
+{
+  return ContainerAlgorithms::Range<typename Range::const_iterator>(
+      range.begin(), range.end());
+}
+
 template<typename Container>
 void cmDeleteAll(Container const& c)
 {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=27c6f017a1ef7c62f7f0332d624add7e8189f81c
commit 27c6f017a1ef7c62f7f0332d624add7e8189f81c
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Jan 14 21:27:25 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:57:55 2015 +0100

    Use cmJoin to accumulate string ranges.
    
    Avoid using the std::accumulate algorithm which is designed for
    numeric types, not complex types.  It introduces unneccessary
    copies.
    
    Initialize variables where they are populated.

diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 8b893bc..212603c 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -217,7 +217,6 @@ bool cmFileCommand
 bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
   bool append)
 {
-  std::string message;
   std::vector<std::string>::const_iterator i = args.begin();
 
   i++; // Get rid of subcommand
@@ -231,10 +230,6 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
 
   i++;
 
-  for(;i != args.end(); ++i)
-    {
-    message += *i;
-    }
   if ( !this->Makefile->CanIWriteThisFile(fileName.c_str()) )
     {
     std::string e
@@ -272,6 +267,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
     this->SetError(error);
     return false;
     }
+  std::string message = cmJoin(cmRange(i, args.end()), std::string());
   file << message;
   file.close();
   if(mode)
diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx
index 88d6a77..0449c50 100644
--- a/Source/cmMessageCommand.cxx
+++ b/Source/cmMessageCommand.cxx
@@ -20,7 +20,6 @@ bool cmMessageCommand
     this->SetError("called with incorrect number of arguments");
     return false;
     }
-  std::string message;
   std::vector<std::string>::const_iterator i = args.begin();
 
   cmake::MessageType type = cmake::MESSAGE;
@@ -70,10 +69,7 @@ bool cmMessageCommand
     ++i;
     }
 
-  for(;i != args.end(); ++i)
-    {
-    message += *i;
-    }
+  std::string message = cmJoin(cmRange(i, args.end()), std::string());
 
   if (type != cmake::MESSAGE)
     {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4e78ebbdf94b99f7b7d5b9b31d05dd9479b1d6ab
commit 4e78ebbdf94b99f7b7d5b9b31d05dd9479b1d6ab
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Feb 10 22:19:21 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:57:55 2015 +0100

    cmAlgorithms: Add a Range container and adaptor method.
    
    This can make a pair of iterators API compatible with the
    cmJoin algorithm and other range-based algorithms.
    
    Accept different iterator types in the cmRange adaptor so that
    a const and non-const iterator are accepted.

diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index 4938140..6c03f51 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -112,6 +112,27 @@ struct DefaultDeleter<Container, /* valueTypeIsPair = */ true>
   }
 };
 
+template<typename const_iterator_>
+struct Range
+{
+  typedef const_iterator_ const_iterator;
+  typedef typename std::iterator_traits<const_iterator>::value_type value_type;
+  Range(const_iterator begin_, const_iterator end_)
+    : Begin(begin_), End(end_) {}
+  const_iterator begin() const { return Begin; }
+  const_iterator end() const { return End; }
+  bool empty() const { return std::distance(Begin, End) == 0; }
+private:
+  const_iterator Begin;
+  const_iterator End;
+};
+
+}
+
+template<typename Iter1, typename Iter2>
+ContainerAlgorithms::Range<Iter1> cmRange(Iter1 begin, Iter2 end)
+{
+  return ContainerAlgorithms::Range<Iter1>(begin, end);
 }
 
 template<typename Container>

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8910224950a2b723e0d4fd7c21a326af7fb2e050
commit 8910224950a2b723e0d4fd7c21a326af7fb2e050
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Jan 14 21:31:46 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:57:55 2015 +0100

    Replace common loop pattern with cmJoin

diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 7746980..fd9b236 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -1064,26 +1064,11 @@ void cmFindPackageCommand::AppendToFoundProperty(bool found)
     }
 
 
-  std::string tmp;
-  const char* sep ="";
-  for(size_t i=0; i<foundContents.size(); i++)
-    {
-    tmp += sep;
-    tmp += foundContents[i];
-    sep = ";";
-    }
-
+  std::string tmp = cmJoin(foundContents, ";");
   this->Makefile->GetCMakeInstance()->SetProperty("PACKAGES_FOUND",
                                                   tmp.c_str());
 
-  tmp = "";
-  sep = "";
-  for(size_t i=0; i<notFoundContents.size(); i++)
-    {
-    tmp += sep;
-    tmp += notFoundContents[i];
-    sep = ";";
-    }
+  tmp = cmJoin(notFoundContents, ";");
   this->Makefile->GetCMakeInstance()->SetProperty("PACKAGES_NOT_FOUND",
                                                   tmp.c_str());
 }
diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx
index c33048c..b44e228 100644
--- a/Source/cmFunctionCommand.cxx
+++ b/Source/cmFunctionCommand.cxx
@@ -193,12 +193,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
     if (!this->Depth)
       {
       std::string name = this->Args[0];
-      std::vector<std::string>::size_type cc;
-      name += "(";
-      for ( cc = 0; cc < this->Args.size(); cc ++ )
-        {
-        name += " " + this->Args[cc];
-        }
+      name += "( ";
+      name += cmJoin(this->Args, " ");
       name += " )";
 
       // create a new command and add it to cmake
diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx
index c0e4683..84c00ba 100644
--- a/Source/cmGetCMakePropertyCommand.cxx
+++ b/Source/cmGetCMakePropertyCommand.cxx
@@ -34,15 +34,7 @@ bool cmGetCMakePropertyCommand
     std::vector<std::string> vars = this->Makefile->GetDefinitions(cacheonly);
     if (!vars.empty())
       {
-      output = "";
-      const char* sep = "";
-      std::vector<std::string>::size_type cc;
-      for ( cc = 0; cc < vars.size(); ++cc )
-        {
-        output += sep;
-        output += vars[cc];
-        sep = ";";
-        }
+      output = cmJoin(vars, ";");
       }
     }
   else if ( args[1] == "MACROS" )
@@ -54,15 +46,7 @@ bool cmGetCMakePropertyCommand
     const std::set<std::string>* components
       = this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
         ->GetInstallComponents();
-    std::set<std::string>::const_iterator compIt;
-    output = "";
-    const char* sep = "";
-    for (compIt = components->begin(); compIt != components->end(); ++compIt)
-      {
-      output += sep;
-      output += *compIt;
-      sep = ";";
-      }
+    output = cmJoin(*components, ";");
     }
   else
     {
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 81aaf3e..676e082 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -197,14 +197,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
               {
               argvDef += ";";
               }
-            const char* sep = "";
-            std::vector<std::string>::const_iterator eit;
-            for(eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit)
-              {
-              argvDef += sep;
-              argvDef += *eit;
-              sep = ";";
-              }
+            argvDef += cmJoin(expandedArgs, ";");
             argvDefInitialized = true;
             }
           cmSystemTools::ReplaceString(tmps, "${ARGV}", argvDef.c_str());
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index aca4413..ac5fec9 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4202,15 +4202,7 @@ const char *cmMakefile::GetProperty(const std::string& prop,
     }
   else if (prop == "LISTFILE_STACK")
     {
-    const char* sep = "";
-    for (std::deque<std::string>::const_iterator
-        i = this->ListFileStack.begin();
-        i != this->ListFileStack.end(); ++i)
-      {
-      output += sep;
-      output += *i;
-      sep = ";";
-      }
+    output = cmJoin(this->ListFileStack, ";");
     return output.c_str();
     }
   else if (prop == "VARIABLES" || prop == "CACHE_VARIABLES")
@@ -4220,14 +4212,7 @@ const char *cmMakefile::GetProperty(const std::string& prop,
       {
       cacheonly = 1;
       }
-    std::vector<std::string> vars = this->GetDefinitions(cacheonly);
-    const char* sep = "";
-    for (unsigned int cc = 0; cc < vars.size(); cc ++ )
-      {
-      output += sep;
-      output += vars[cc];
-      sep = ";";
-      }
+    output = cmJoin(this->GetDefinitions(cacheonly), ";");
     return output.c_str();
     }
   else if (prop == "MACROS")
@@ -4242,16 +4227,7 @@ const char *cmMakefile::GetProperty(const std::string& prop,
     }
   else if (prop == "LINK_DIRECTORIES")
     {
-    const char* sep = "";
-    for (std::vector<std::string>::const_iterator
-         it = this->GetLinkDirectories().begin();
-         it != this->GetLinkDirectories().end();
-         ++ it )
-      {
-      output += sep;
-      output += *it;
-      sep = ";";
-      }
+    output = cmJoin(this->GetLinkDirectories(), ";");
     return output.c_str();
     }
   else if (prop == "INCLUDE_DIRECTORIES")
diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx
index e505440..60728ea 100644
--- a/Source/cmOptionCommand.cxx
+++ b/Source/cmOptionCommand.cxx
@@ -34,11 +34,7 @@ bool cmOptionCommand
   if(argError)
     {
     std::string m = "called with incorrect number of arguments: ";
-    for(size_t i =0; i < args.size(); ++i)
-      {
-      m += args[i];
-      m += " ";
-      }
+    m += cmJoin(args, " ");
     this->SetError(m);
     return false;
     }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7b8725bf8472ebf4781ddd60ef8fcca9c3ad98dd
commit 7b8725bf8472ebf4781ddd60ef8fcca9c3ad98dd
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Jan 17 17:36:19 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:57:53 2015 +0100

    Convert loops populating maybe-empty content into the common pattern.

diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index 107dca9..8d1657d 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -254,14 +254,18 @@ bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args)
   // expand the variable
   std::string listString;
   this->GetListString(listString, listName);
+
+  if(!listString.empty() && !args.empty())
+    {
+    listString += ";";
+    }
+  const char* sep = "";
   size_t cc;
   for ( cc = 2; cc < args.size(); ++ cc )
     {
-    if(!listString.empty())
-      {
-      listString += ";";
-      }
+    listString += sep;
     listString += args[cc];
+    sep = ";";
     }
 
   this->Makefile->AddDefinition(listName, listString.c_str());
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 7afe05f..05d8ab5 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -3011,13 +3011,17 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
   // trailing slash in the input then the last iteration of the loop
   // will add a slash followed by an empty string which will preserve
   // the trailing slash in the output.
+
+  if(!relative.empty() && !remote.empty())
+    {
+    relative += "/";
+    }
+  const char* sep = "";
   for(unsigned int i=common; i < remote.size(); ++i)
     {
-    if(!relative.empty())
-      {
-      relative += "/";
-      }
+    relative += sep;
     relative += remote[i];
+    sep = "/";
     }
 
   // Finally return the path.
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 657e750..81aaf3e 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -166,15 +166,17 @@ bool cmMacroHelperCommand::InvokeInitialPass
             {
             if (expandedArgs.size() > this->Args.size() - 1)
               {
+              if (!argnDef.empty() && !expandedArgs.empty())
+                {
+                argnDef += ";";
+                }
               std::vector<std::string>::const_iterator eit
                   = expandedArgs.begin() + (this->Args.size() - 1);
+              const char* sep = "";
               for( ; eit != expandedArgs.end(); ++eit)
                 {
-                if (!argnDef.empty())
-                  {
-                  argnDef += ";";
-                  }
-                argnDef += *eit;
+                argnDef += sep + *eit;
+                sep = ";";
                 }
               }
             argnDefInitialized = true;
@@ -191,14 +193,17 @@ bool cmMacroHelperCommand::InvokeInitialPass
           // repleace ARGV, compute it only once
           if (!argvDefInitialized)
             {
+            if (!argvDef.empty() && !expandedArgs.empty())
+              {
+              argvDef += ";";
+              }
+            const char* sep = "";
             std::vector<std::string>::const_iterator eit;
             for(eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit)
               {
-              if (!argvDef.empty())
-                {
-                argvDef += ";";
-                }
+              argvDef += sep;
               argvDef += *eit;
+              sep = ";";
               }
             argvDefInitialized = true;
             }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7ee56f03999e8605cc2cbe85a3a7b7159e639e5d
commit 7ee56f03999e8605cc2cbe85a3a7b7159e639e5d
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Jan 17 17:47:10 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:57:41 2015 +0100

    Convert loops into the commonly used pattern.

diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx
index e193cf5..c0e4683 100644
--- a/Source/cmGetCMakePropertyCommand.cxx
+++ b/Source/cmGetCMakePropertyCommand.cxx
@@ -25,7 +25,6 @@ bool cmGetCMakePropertyCommand
     return false;
     }
 
-  std::vector<std::string>::size_type cc;
   std::string variable = args[0];
   std::string output = "NOTFOUND";
 
@@ -35,12 +34,15 @@ bool cmGetCMakePropertyCommand
     std::vector<std::string> vars = this->Makefile->GetDefinitions(cacheonly);
     if (!vars.empty())
       {
-      output = vars[0];
-      }
-    for ( cc = 1; cc < vars.size(); ++cc )
-      {
-      output += ";";
-      output += vars[cc];
+      output = "";
+      const char* sep = "";
+      std::vector<std::string>::size_type cc;
+      for ( cc = 0; cc < vars.size(); ++cc )
+        {
+        output += sep;
+        output += vars[cc];
+        sep = ";";
+        }
       }
     }
   else if ( args[1] == "MACROS" )
@@ -54,13 +56,12 @@ bool cmGetCMakePropertyCommand
         ->GetInstallComponents();
     std::set<std::string>::const_iterator compIt;
     output = "";
+    const char* sep = "";
     for (compIt = components->begin(); compIt != components->end(); ++compIt)
       {
-      if (compIt != components->begin())
-        {
-        output += ";";
-        }
+      output += sep;
       output += *compIt;
+      sep = ";";
       }
     }
   else
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index eb68e49..aca4413 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -3752,15 +3752,12 @@ void cmMakefile::GetListOfMacros(std::string& macros) const
 {
   StringStringMap::const_iterator it;
   macros = "";
-  int cc = 0;
+  const char* sep = "";
   for ( it = this->MacrosMap.begin(); it != this->MacrosMap.end(); ++it )
     {
-    if ( cc > 0 )
-      {
-      macros += ";";
-      }
+    macros += sep;
     macros += it->first;
-    cc ++;
+    sep = "";
     }
 }
 
@@ -4205,15 +4202,14 @@ const char *cmMakefile::GetProperty(const std::string& prop,
     }
   else if (prop == "LISTFILE_STACK")
     {
+    const char* sep = "";
     for (std::deque<std::string>::const_iterator
         i = this->ListFileStack.begin();
         i != this->ListFileStack.end(); ++i)
       {
-      if (i != this->ListFileStack.begin())
-        {
-        output += ";";
-        }
+      output += sep;
       output += *i;
+      sep = ";";
       }
     return output.c_str();
     }
@@ -4225,13 +4221,12 @@ const char *cmMakefile::GetProperty(const std::string& prop,
       cacheonly = 1;
       }
     std::vector<std::string> vars = this->GetDefinitions(cacheonly);
+    const char* sep = "";
     for (unsigned int cc = 0; cc < vars.size(); cc ++ )
       {
-      if ( cc > 0 )
-        {
-        output += ";";
-        }
+      output += sep;
       output += vars[cc];
+      sep = ";";
       }
     return output.c_str();
     }
@@ -4247,19 +4242,16 @@ const char *cmMakefile::GetProperty(const std::string& prop,
     }
   else if (prop == "LINK_DIRECTORIES")
     {
-    std::ostringstream str;
+    const char* sep = "";
     for (std::vector<std::string>::const_iterator
          it = this->GetLinkDirectories().begin();
          it != this->GetLinkDirectories().end();
          ++ it )
       {
-      if ( it != this->GetLinkDirectories().begin())
-        {
-        str << ";";
-        }
-      str << it->c_str();
+      output += sep;
+      output += *it;
+      sep = ";";
       }
-    output = str.str();
     return output.c_str();
     }
   else if (prop == "INCLUDE_DIRECTORIES")

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0a4e5674eccb0126733086d4632c7239217db6f1
commit 0a4e5674eccb0126733086d4632c7239217db6f1
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jan 25 15:47:21 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Feb 11 22:57:38 2015 +0100

    cmMacroCommand: Remove counting variable.
    
    Start iteration at correct starting point directly.

diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index c1e7cbb..657e750 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -167,19 +167,14 @@ bool cmMacroHelperCommand::InvokeInitialPass
             if (expandedArgs.size() > this->Args.size() - 1)
               {
               std::vector<std::string>::const_iterator eit
-                  = expandedArgs.begin();
-              std::vector<std::string>::size_type cnt = 0;
+                  = expandedArgs.begin() + (this->Args.size() - 1);
               for( ; eit != expandedArgs.end(); ++eit)
                 {
-                if ( cnt >= this->Args.size()-1 )
+                if (!argnDef.empty())
                   {
-                  if (!argnDef.empty())
-                    {
-                    argnDef += ";";
-                    }
-                  argnDef += *eit;
+                  argnDef += ";";
                   }
-                cnt ++;
+                argnDef += *eit;
                 }
               }
             argnDefInitialized = true;

-----------------------------------------------------------------------

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list