[Cmake-commits] CMake branch, next, updated. v3.0.0-3685-g93f55d8

Ben Boeckel ben.boeckel at kitware.com
Tue Jun 10 15:12:37 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  93f55d8f32898c524862cc398f518bbfa0954b0d (commit)
       via  e17a69bc744ce0ed36e41be36694ca0053330d78 (commit)
       via  3b21705d534c16a6197f28db68ea81e2816bfec3 (commit)
       via  5abfde6cb8a1ae0b2825797eab6c2e9842eb7c49 (commit)
      from  8804320539e406a9ed2fdd5aa17bb152c8ff0eea (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=93f55d8f32898c524862cc398f518bbfa0954b0d
commit 93f55d8f32898c524862cc398f518bbfa0954b0d
Merge: 8804320 e17a69b
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Tue Jun 10 15:12:36 2014 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Jun 10 15:12:36 2014 -0400

    Merge topic 'dev/variable-lookup' into next
    
    e17a69bc cmDefinitions: Use a hashmap for faster checks
    3b21705d cmDefinitions: Avoid a find-then-insert when setting variables
    5abfde6c cmDefinitions: Don't store parent lookups


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e17a69bc744ce0ed36e41be36694ca0053330d78
commit e17a69bc744ce0ed36e41be36694ca0053330d78
Author:     Ben Boeckel <mathstuf at gmail.com>
AuthorDate: Wed Mar 12 01:48:06 2014 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Mon Jun 9 14:46:45 2014 -0400

    cmDefinitions: Use a hashmap for faster checks
    
    The hash map is much faster at checking that the map won't have what
    we're looking for so that we can just go to the parent scope instead.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 6502163..5515f35 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -15,7 +15,8 @@
 cmDefinitions::Def cmDefinitions::NoDef;
 
 //----------------------------------------------------------------------------
-cmDefinitions::cmDefinitions(cmDefinitions* parent): Up(parent)
+cmDefinitions::cmDefinitions(cmDefinitions* parent)
+  : Up(parent)
 {
 }
 
@@ -35,7 +36,7 @@ cmDefinitions::GetInternal(const std::string& key) const
     {
     return i->second;
     }
-  else if(cmDefinitions* up = this->Up)
+  if(cmDefinitions* up = this->Up)
     {
     // Query the parent scope.
     return up->GetInternal(key);
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index ebe6fa5..5209a8b 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -13,6 +13,9 @@
 #define cmDefinitions_h
 
 #include "cmStandardIncludes.h"
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+#include "cmsys/hash_map.hxx"
+#endif
 
 /** \class cmDefinitions
  * \brief Store a scope of variable definitions for CMake language.
@@ -71,7 +74,11 @@ private:
   cmDefinitions* Up;
 
   // Local definitions, set or unset.
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+  typedef cmsys::hash_map<std::string, Def> MapType;
+#else
   typedef std::map<std::string, Def> MapType;
+#endif
   MapType Map;
 
   // Internal query and update methods.

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3b21705d534c16a6197f28db68ea81e2816bfec3
commit 3b21705d534c16a6197f28db68ea81e2816bfec3
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Wed Mar 12 14:03:41 2014 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Mon Jun 9 14:46:45 2014 -0400

    cmDefinitions: Avoid a find-then-insert when setting variables
    
    Searching the map is not necessary.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 98becf8..6502163 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -50,16 +50,7 @@ cmDefinitions::SetInternal(const std::string& key, Def const& def)
   if(this->Up || def.Exists)
     {
     // In lower scopes we store keys, defined or not.
-    MapType::iterator i = this->Map.find(key);
-    if(i == this->Map.end())
-      {
-      i = this->Map.insert(MapType::value_type(key, def)).first;
-      }
-    else
-      {
-      i->second = def;
-      }
-    return i->second;
+    return (this->Map[key] = def);
     }
   else
     {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5abfde6cb8a1ae0b2825797eab6c2e9842eb7c49
commit 5abfde6cb8a1ae0b2825797eab6c2e9842eb7c49
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Wed Mar 12 14:01:45 2014 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Mon Jun 9 14:46:45 2014 -0400

    cmDefinitions: Don't store parent lookups
    
    When looking up scopes, it is faster to not store the lookup locally to
    keep the maps smaller and avoid extra allocations and rebalancing.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index babf1c4..98becf8 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -28,7 +28,7 @@ void cmDefinitions::Reset(cmDefinitions* parent)
 
 //----------------------------------------------------------------------------
 cmDefinitions::Def const&
-cmDefinitions::GetInternal(const std::string& key)
+cmDefinitions::GetInternal(const std::string& key) const
 {
   MapType::const_iterator i = this->Map.find(key);
   if(i != this->Map.end())
@@ -37,9 +37,8 @@ cmDefinitions::GetInternal(const std::string& key)
     }
   else if(cmDefinitions* up = this->Up)
     {
-    // Query the parent scope and store the result locally.
-    Def def = up->GetInternal(key);
-    return this->Map.insert(MapType::value_type(key, def)).first->second;
+    // Query the parent scope.
+    return up->GetInternal(key);
     }
   return this->NoDef;
 }
@@ -71,13 +70,26 @@ cmDefinitions::SetInternal(const std::string& key, Def const& def)
 }
 
 //----------------------------------------------------------------------------
-const char* cmDefinitions::Get(const std::string& key)
+const char* cmDefinitions::Get(const std::string& key) const
 {
   Def const& def = this->GetInternal(key);
   return def.Exists? def.c_str() : 0;
 }
 
 //----------------------------------------------------------------------------
+void cmDefinitions::Pull(const std::string& key)
+{
+  if (this->Up)
+    {
+    Def const& def = this->Up->GetInternal(key);
+    if (def.Exists)
+      {
+      this->SetInternal(key, def);
+      }
+    }
+}
+
+//----------------------------------------------------------------------------
 const char* cmDefinitions::Set(const std::string& key, const char* value)
 {
   Def const& def = this->SetInternal(key, Def(value));
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index d615fb0..ebe6fa5 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -33,9 +33,11 @@ public:
   /** Returns the parent scope, if any.  */
   cmDefinitions* GetParent() const { return this->Up; }
 
-  /** Get the value associated with a key; null if none.
-      Store the result locally if it came from a parent.  */
-  const char* Get(const std::string& key);
+  /** Get the value associated with a key; null if none. */
+  const char* Get(const std::string& key) const;
+
+  /** Pull a variable from the parent. */
+  void Pull(const std::string& key);
 
   /** Set (or unset if null) a value associated with a key.  */
   const char* Set(const std::string& key, const char* value);
@@ -73,7 +75,7 @@ private:
   MapType Map;
 
   // Internal query and update methods.
-  Def const& GetInternal(const std::string& key);
+  Def const& GetInternal(const std::string& key) const;
   Def const& SetInternal(const std::string& key, Def const& def);
 
   // Implementation of Closure() method.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 630957f..412c998 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4422,7 +4422,7 @@ void cmMakefile::RaiseScope(const std::string& var, const char *varDef)
   if(cmDefinitions* up = cur.GetParent())
     {
     // First localize the definition in the current scope.
-    cur.Get(var);
+    cur.Pull(var);
 
     // Now update the definition in the parent scope.
     up->Set(var, varDef);

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

Summary of changes:
 Source/cmDefinitions.cxx |   38 +++++++++++++++++++++-----------------
 Source/cmDefinitions.h   |   17 +++++++++++++----
 Source/cmMakefile.cxx    |    2 +-
 3 files changed, 35 insertions(+), 22 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list