[Cmake-commits] CMake branch, next, updated. v3.0.0-4244-gddd524e

Ben Boeckel ben.boeckel at kitware.com
Mon Jul 14 15:19:47 EDT 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  ddd524eeba6310b556339471a6830469843d836b (commit)
       via  43a8c5526d12c1346793ced5a4be85b9e9a3d695 (commit)
       via  9270aa9a2d1ea05e7bd63ef5214f4fbaafd14d2e (commit)
      from  90ecd1721f2c2bcc7e2302c047e040a437c03aa5 (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=ddd524eeba6310b556339471a6830469843d836b
commit ddd524eeba6310b556339471a6830469843d836b
Merge: 90ecd17 43a8c55
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Mon Jul 14 15:19:47 2014 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Jul 14 15:19:47 2014 -0400

    Merge topic 'dev/ison-isoff-performance' into next
    
    43a8c552 SystemTools: Use a set in Is{On,Off}
    9270aa9a IsOff: Use the length for the string construction


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=43a8c5526d12c1346793ced5a4be85b9e9a3d695
commit 43a8c5526d12c1346793ced5a4be85b9e9a3d695
Author:     Ben Boeckel <mathstuf at gmail.com>
AuthorDate: Sat Feb 8 05:42:14 2014 -0500
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Tue Jul 8 11:18:15 2014 -0400

    SystemTools: Use a set in Is{On,Off}
    
    Also check before calling toupper() umpteen million times.

diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index aa39c39..444e143 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -384,14 +384,28 @@ bool cmSystemTools::IsOn(const char* val)
     {
     return false;
     }
-  std::basic_string<char> v = val;
+  size_t len = strlen(val);
+  if (len > 4)
+    {
+    return false;
+    }
+  std::basic_string<char> v(val, len);
 
+  static std::set<std::string> onValues;
+  if(onValues.empty())
+    {
+    onValues.insert("ON");
+    onValues.insert("1");
+    onValues.insert("YES");
+    onValues.insert("TRUE");
+    onValues.insert("Y");
+    }
   for(std::basic_string<char>::iterator c = v.begin();
       c != v.end(); c++)
     {
     *c = static_cast<char>(toupper(*c));
     }
-  return (v == "ON" || v == "1" || v == "YES" || v == "TRUE" || v == "Y");
+  return (onValues.count(v) > 0);
 }
 
 bool cmSystemTools::IsNOTFOUND(const char* val)
@@ -410,16 +424,31 @@ bool cmSystemTools::IsOff(const char* val)
     {
     return true;
     }
-  size_t len = val ? strlen(val) : 0;
-  std::basic_string<char> v(val, len);
+  size_t len = strlen(val);
+  // Try and avoid toupper() for large strings.
+  if (len > 6)
+    {
+    return cmSystemTools::IsNOTFOUND(val);
+    }
 
+  static std::set<std::string> offValues;
+  if(offValues.empty())
+    {
+    offValues.insert("OFF");
+    offValues.insert("0");
+    offValues.insert("NO");
+    offValues.insert("FALSE");
+    offValues.insert("N");
+    offValues.insert("IGNORE");
+    }
+  // Try and avoid toupper().
+  std::basic_string<char> v(val, len);
   for(std::basic_string<char>::iterator c = v.begin();
       c != v.end(); c++)
     {
     *c = static_cast<char>(toupper(*c));
     }
-  return (v == "OFF" || v == "0" || v == "NO" || v == "FALSE" ||
-          v == "N" || cmSystemTools::IsNOTFOUND(v.c_str()) || v == "IGNORE");
+  return (offValues.count(v) > 0);
 }
 
 //----------------------------------------------------------------------------

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9270aa9a2d1ea05e7bd63ef5214f4fbaafd14d2e
commit 9270aa9a2d1ea05e7bd63ef5214f4fbaafd14d2e
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Mon Sep 2 16:28:21 2013 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Tue Jul 8 11:16:16 2014 -0400

    IsOff: Use the length for the string construction
    
    No need to waste the calculation and force the string to call strlen
    again.

diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 12a63b0..aa39c39 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -406,11 +406,12 @@ bool cmSystemTools::IsNOTFOUND(const char* val)
 
 bool cmSystemTools::IsOff(const char* val)
 {
-  if (!val || strlen(val) == 0)
+  if (!val || !*val)
     {
     return true;
     }
-  std::basic_string<char> v = val;
+  size_t len = val ? strlen(val) : 0;
+  std::basic_string<char> v(val, len);
 
   for(std::basic_string<char>::iterator c = v.begin();
       c != v.end(); c++)

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

Summary of changes:
 Source/cmSystemTools.cxx |   42 ++++++++++++++++++++++++++++++++++++------
 1 file changed, 36 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list