[Cmake-commits] CMake branch, next, updated. v2.8.12.2-7780-g4803404

Ben Boeckel ben.boeckel at kitware.com
Tue Feb 18 11:03:59 EST 2014


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  4803404d0ff7b27e4502a9ea1aaba722ffc901a6 (commit)
       via  dd777124903ed5e39ee02a66a5eec22c0ceafc2f (commit)
       via  c5f4fb5f7cf2dc2e1dfcd6b3f145e79e25f25845 (commit)
       via  2563c48495d379ec27084511571c5c7b14f83c34 (commit)
       via  52fc5d48978129d581453f2d72655cad6be3107b (commit)
      from  5bffed2ab24c822c62e9667f999d9a8d7e0da09a (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=4803404d0ff7b27e4502a9ea1aaba722ffc901a6
commit 4803404d0ff7b27e4502a9ea1aaba722ffc901a6
Merge: 5bffed2 dd77712
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Tue Feb 18 11:03:58 2014 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Feb 18 11:03:58 2014 -0500

    Merge topic 'dev/faster-parsers' into next
    
    dd777124 relnotes: Add release notes for the branch
    c5f4fb5f cmGeneratorExpression: Improve parsing in StripEmptyListElements
    2563c484 cmGeneratorExpressionLexer: Use a switch statement to parse
    52fc5d48 ExpandListArguments: Optimize the parser


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dd777124903ed5e39ee02a66a5eec22c0ceafc2f
commit dd777124903ed5e39ee02a66a5eec22c0ceafc2f
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Tue Feb 11 13:54:07 2014 -0500
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Tue Feb 18 10:57:21 2014 -0500

    relnotes: Add release notes for the branch

diff --git a/Help/release/dev/faster-parsers.rst b/Help/release/dev/faster-parsers.rst
new file mode 100644
index 0000000..c2a8bfb
--- /dev/null
+++ b/Help/release/dev/faster-parsers.rst
@@ -0,0 +1,6 @@
+faster-parsers
+--------------
+
+* The :manual:`cmake-language(7)` internal implementation of generator
+  expression and list expansion parsers have been optimized and shows
+  non-trivial speedup on large projects.

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c5f4fb5f7cf2dc2e1dfcd6b3f145e79e25f25845
commit c5f4fb5f7cf2dc2e1dfcd6b3f145e79e25f25845
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Sun Feb 9 05:09:52 2014 -0500
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Tue Feb 18 10:25:33 2014 -0500

    cmGeneratorExpression: Improve parsing in StripEmptyListElements
    
    The char-by-char parsing causes lots of reallocations which shouldn't be
    necessary. To improve this, fast-path strings without a semicolon,
    reserve space in the result, and insert into the result in chunks.

diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index 2e66d78..cd30546 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -157,17 +157,24 @@ cmCompiledGeneratorExpression::~cmCompiledGeneratorExpression()
 std::string cmGeneratorExpression::StripEmptyListElements(
                                                     const std::string &input)
 {
+  if (input.find(';') == input.npos)
+    {
+    return input;
+    }
   std::string result;
+  result.reserve(input.size());
 
   const char *c = input.c_str();
+  const char *last = c;
   bool skipSemiColons = true;
   for ( ; *c; ++c)
     {
-    if(c[0] == ';')
+    if(*c == ';')
       {
       if(skipSemiColons)
         {
-        continue;
+        result.append(last, c - last);
+        last = c + 1;
         }
       skipSemiColons = true;
       }
@@ -175,8 +182,8 @@ std::string cmGeneratorExpression::StripEmptyListElements(
       {
       skipSemiColons = false;
       }
-    result += *c;
     }
+  result.append(last);
 
   if (!result.empty() && *(result.end() - 1) == ';')
     {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2563c48495d379ec27084511571c5c7b14f83c34
commit 2563c48495d379ec27084511571c5c7b14f83c34
Author:     Ben Boeckel <mathstuf at gmail.com>
AuthorDate: Sat Feb 8 12:01:30 2014 -0500
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Tue Feb 18 10:25:33 2014 -0500

    cmGeneratorExpressionLexer: Use a switch statement to parse
    
    Optimize cmGeneratorExpressionLexer::Tokenize to use a switch statement.
    The many dereferences of the input pointer were expensive. Also remove
    excess pointer arithmetic.

diff --git a/Source/cmGeneratorExpressionLexer.cxx b/Source/cmGeneratorExpressionLexer.cxx
index cd71ec0..117a24e 100644
--- a/Source/cmGeneratorExpressionLexer.cxx
+++ b/Source/cmGeneratorExpressionLexer.cxx
@@ -42,42 +42,42 @@ cmGeneratorExpressionLexer::Tokenize(const char *input)
   const char *upto = c;
 
   for ( ; *c; ++c)
-  {
-  if(c[0] == '$' && c[1] == '<')
     {
-    InsertText(upto, c, result);
-    upto = c;
-    result.push_back(cmGeneratorExpressionToken(
-                      cmGeneratorExpressionToken::BeginExpression, upto, 2));
-    upto = c + 2;
-    ++c;
-    SawBeginExpression = true;
-    }
-  else if(c[0] == '>')
-    {
-    InsertText(upto, c, result);
-    upto = c;
-    result.push_back(cmGeneratorExpressionToken(
-                        cmGeneratorExpressionToken::EndExpression, upto, 1));
-    upto = c + 1;
-    SawGeneratorExpression = SawBeginExpression;
-    }
-  else if(c[0] == ':')
-    {
-    InsertText(upto, c, result);
-    upto = c;
-    result.push_back(cmGeneratorExpressionToken(
-                        cmGeneratorExpressionToken::ColonSeparator, upto, 1));
-    upto = c + 1;
-    }
-  else if(c[0] == ',')
-    {
-    InsertText(upto, c, result);
-    upto = c;
-    result.push_back(cmGeneratorExpressionToken(
-                        cmGeneratorExpressionToken::CommaSeparator, upto, 1));
-    upto = c + 1;
-    }
+    switch(*c)
+      {
+      case '$':
+        if(c[1] == '<')
+          {
+          InsertText(upto, c, result);
+          result.push_back(cmGeneratorExpressionToken(
+                           cmGeneratorExpressionToken::BeginExpression, c, 2));
+          upto = c + 2;
+          ++c;
+          SawBeginExpression = true;
+          }
+        break;
+      case '>':
+        InsertText(upto, c, result);
+        result.push_back(cmGeneratorExpressionToken(
+                            cmGeneratorExpressionToken::EndExpression, c, 1));
+        upto = c + 1;
+        SawGeneratorExpression = SawBeginExpression;
+        break;
+      case ':':
+        InsertText(upto, c, result);
+        result.push_back(cmGeneratorExpressionToken(
+                            cmGeneratorExpressionToken::ColonSeparator, c, 1));
+        upto = c + 1;
+        break;
+      case ',':
+        InsertText(upto, c, result);
+        result.push_back(cmGeneratorExpressionToken(
+                            cmGeneratorExpressionToken::CommaSeparator, c, 1));
+        upto = c + 1;
+        break;
+      default:
+        break;
+      }
   }
   InsertText(upto, c, result);
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=52fc5d48978129d581453f2d72655cad6be3107b
commit 52fc5d48978129d581453f2d72655cad6be3107b
Author:     Ben Boeckel <mathstuf at gmail.com>
AuthorDate: Sat Feb 8 11:35:52 2014 -0500
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Tue Feb 18 10:25:33 2014 -0500

    ExpandListArguments: Optimize the parser
    
    Optimize cmSystemTools::ExpandListArguments so as not to build a string
    character-by-character. This avoids excess reallocations of the result
    string.

diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 41c7509..7c4aa41 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1006,7 +1006,7 @@ void cmSystemTools::ExpandListArgument(const std::string& arg,
                                        bool emptyArgs)
 {
   // If argument is empty, it is an empty list.
-  if(arg.length() == 0 && !emptyArgs)
+  if(!emptyArgs && arg.empty())
     {
     return;
     }
@@ -1016,10 +1016,11 @@ void cmSystemTools::ExpandListArgument(const std::string& arg,
     newargs.push_back(arg);
     return;
     }
-  std::vector<char> newArgVec;
+  std::string newArg;
+  const char *last = arg.c_str();
   // Break the string at non-escaped semicolons not nested in [].
   int squareNesting = 0;
-  for(const char* c = arg.c_str(); *c; ++c)
+  for(const char* c = last; *c; ++c)
     {
     switch(*c)
       {
@@ -1027,34 +1028,21 @@ void cmSystemTools::ExpandListArgument(const std::string& arg,
         {
         // We only want to allow escaping of semicolons.  Other
         // escapes should not be processed here.
-        ++c;
-        if(*c == ';')
-          {
-          newArgVec.push_back(*c);
-          }
-        else
+        const char* next = c + 1;
+        if(*next == ';')
           {
-          newArgVec.push_back('\\');
-          if(*c)
-            {
-            newArgVec.push_back(*c);
-            }
-          else
-            {
-            // Terminate the loop properly.
-            --c;
-            }
+          newArg.append(last, c - last);
+          // Skip over the escape character
+          last = c = next;
           }
         } break;
       case '[':
         {
         ++squareNesting;
-        newArgVec.push_back(*c);
         } break;
       case ']':
         {
         --squareNesting;
-        newArgVec.push_back(*c);
         } break;
       case ';':
         {
@@ -1062,31 +1050,28 @@ void cmSystemTools::ExpandListArgument(const std::string& arg,
         // brackets.
         if(squareNesting == 0)
           {
-          if ( newArgVec.size() || emptyArgs )
+          newArg.append(last, c - last);
+          // Skip over the semicolon
+          last = c + 1;
+          if ( !newArg.empty() || emptyArgs )
             {
             // Add the last argument if the string is not empty.
-            newArgVec.push_back(0);
-            newargs.push_back(&*newArgVec.begin());
-            newArgVec.clear();
+            newargs.push_back(newArg);
+            newArg = "";
             }
           }
-        else
-          {
-          newArgVec.push_back(*c);
-          }
         } break;
       default:
         {
         // Just append this character.
-        newArgVec.push_back(*c);
         } break;
       }
     }
-  if ( newArgVec.size() || emptyArgs )
+  newArg.append(last);
+  if ( !newArg.empty() || emptyArgs )
     {
     // Add the last argument if the string is not empty.
-    newArgVec.push_back(0);
-    newargs.push_back(&*newArgVec.begin());
+    newargs.push_back(newArg);
     }
 }
 

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

Summary of changes:
 Help/release/dev/faster-parsers.rst   |    6 +++
 Source/cmGeneratorExpression.cxx      |   13 ++++--
 Source/cmGeneratorExpressionLexer.cxx |   70 ++++++++++++++++-----------------
 Source/cmSystemTools.cxx              |   51 +++++++++---------------
 4 files changed, 69 insertions(+), 71 deletions(-)
 create mode 100644 Help/release/dev/faster-parsers.rst


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list