[Cmake-commits] CMake branch, next, updated. v3.2.2-2342-gd98fde5

Stephen Kelly steveire at gmail.com
Wed Apr 29 18:51:56 EDT 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  d98fde519e88e42992fa174bf033d6a3c431b6c5 (commit)
       via  569982ecf4aadbf5e53ed0f31a4397ea98e5c614 (commit)
       via  818820153b43578eebf9d4c5295423e6adf1f787 (commit)
       via  d904debd50920aa1b12360ba5291931adb2c8ee5 (commit)
       via  ad831a56ec910ea06b44189d04d52a5f84518432 (commit)
       via  82a57e665bc22e6d5e74211210e35fa8c8238019 (commit)
       via  f9b42dc5964f040fff4682274a14f89ab3c0f36a (commit)
       via  2b9015cb45bae66fd368b61de2db6b2c7527b42e (commit)
       via  825a44b30443e42495606357f677b4fa70e0e6f9 (commit)
       via  33a9cb0a05844f295dc0ba840febc21cbdd082ee (commit)
       via  15cfac49a65ae7d22855951bf5824b3541255128 (commit)
       via  5643d935bd5851d42982cc18cc1f6851dc80251b (commit)
       via  b48ea26a9d3b4384874554fe64edfce8784a9255 (commit)
      from  a14d6b039db25d374ae0c4740e79e78d55b9072f (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=d98fde519e88e42992fa174bf033d6a3c431b6c5
commit d98fde519e88e42992fa174bf033d6a3c431b6c5
Merge: a14d6b0 569982e
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Apr 29 18:51:52 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Apr 29 18:51:52 2015 -0400

    Merge topic 'refactor-cmDefinitions-Get' into next
    
    569982ec cmDefinitions: Remove Parent pointer.
    81882015 cmDefinitions: Inline GetInternal into Get.
    d904debd cmDefinitions: Externalize the stack loop for the Get method.
    ad831a56 cmMakefile: Implement RaiseScope in terms of local Get method.
    82a57e66 cmMakefile: Implement RaiseScope without relying on Parent.
    f9b42dc5 cmDefinitions: Extract loop from GetInternal to Get.
    2b9015cb cmDefinitions: Use Set API in Get implementation.
    825a44b3 cmDefinitions: Use map::operator[] in Get.
    33a9cb0a cmDefinitions: Simplify API of GetInternal.
    15cfac49 cmDefinitions: Remove conditionals before loop.
    5643d935 cmDefinitions: Replace GetInternal recursion with looping.
    b48ea26a cmDefinitions: Invert conditional code.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=569982ecf4aadbf5e53ed0f31a4397ea98e5c614
commit 569982ecf4aadbf5e53ed0f31a4397ea98e5c614
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 16:19:11 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 00:41:13 2015 +0200

    cmDefinitions: Remove Parent pointer.
    
    All structural knowledge of the stack of scopes is now external.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 7789e57..13ebf7b 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -12,12 +12,6 @@
 #include "cmDefinitions.h"
 
 //----------------------------------------------------------------------------
-cmDefinitions::cmDefinitions(cmDefinitions* parent)
-  : Up(parent)
-{
-}
-
-//----------------------------------------------------------------------------
 std::pair<const char*, bool> cmDefinitions::Get(const std::string& key)
 {
   MapType::const_iterator i = this->Map.find(key);
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 6813c82..a698090 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -28,12 +28,6 @@
 class cmDefinitions
 {
 public:
-  /** Construct with the given parent scope.  */
-  cmDefinitions(cmDefinitions* parent = 0);
-
-  /** Returns the parent scope, if any.  */
-  cmDefinitions* GetParent() const { return this->Up; }
-
   std::pair<const char*, bool> Get(const std::string& key);
 
   /** Set (or unset if null) a value associated with a key.  */
@@ -65,9 +59,6 @@ private:
     bool Exists;
   };
 
-  // Parent scope, if any.
-  cmDefinitions* Up;
-
   // Local definitions, set or unset.
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   typedef cmsys::hash_map<std::string, Def> MapType;
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 9a9d53d..b8e9148 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -53,12 +53,7 @@ public:
 
   void PushDefinitions()
   {
-    cmDefinitions* parent = 0;
-    if (!this->VarStack.empty())
-      {
-      parent = &this->VarStack.back();
-      }
-    this->VarStack.push_back(cmDefinitions(parent));
+    this->VarStack.push_back(cmDefinitions());
   }
 
   void InitializeDefinitions(cmMakefile* parent)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=818820153b43578eebf9d4c5295423e6adf1f787
commit 818820153b43578eebf9d4c5295423e6adf1f787
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:08:30 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 00:41:13 2015 +0200

    cmDefinitions: Inline GetInternal into Get.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index b422f51..7789e57 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -18,7 +18,7 @@ cmDefinitions::cmDefinitions(cmDefinitions* parent)
 }
 
 //----------------------------------------------------------------------------
-std::pair<const char*, bool> cmDefinitions::GetInternal(const std::string& key)
+std::pair<const char*, bool> cmDefinitions::Get(const std::string& key)
 {
   MapType::const_iterator i = this->Map.find(key);
   std::pair<const char*, bool> result((const char*)0, false);
@@ -30,12 +30,6 @@ std::pair<const char*, bool> cmDefinitions::GetInternal(const std::string& key)
 }
 
 //----------------------------------------------------------------------------
-std::pair<const char*, bool> cmDefinitions::Get(const std::string& key)
-{
-  return this->GetInternal(key);
-}
-
-//----------------------------------------------------------------------------
 void cmDefinitions::Set(const std::string& key, const char* value)
 {
   Def def(value);
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index b8f9fa3..6813c82 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -76,9 +76,6 @@ private:
 #endif
   MapType Map;
 
-  // Internal query and update methods.
-  std::pair<const char*, bool> GetInternal(const std::string& key);
-
   void MakeClosure(std::set<std::string>& undefined,
                    std::list<cmDefinitions>::const_reverse_iterator rbegin,
                    std::list<cmDefinitions>::const_reverse_iterator rend);

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d904debd50920aa1b12360ba5291931adb2c8ee5
commit d904debd50920aa1b12360ba5291931adb2c8ee5
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 13:10:43 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 00:39:41 2015 +0200

    cmDefinitions: Externalize the stack loop for the Get method.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 10f780c..b422f51 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -30,28 +30,9 @@ std::pair<const char*, bool> cmDefinitions::GetInternal(const std::string& key)
 }
 
 //----------------------------------------------------------------------------
-const char* cmDefinitions::Get(const std::string& key)
+std::pair<const char*, bool> cmDefinitions::Get(const std::string& key)
 {
-  std::list<cmDefinitions*> ups;
-  cmDefinitions* up = this;
-  std::pair<const char*, bool> result((const char*)0, false);
-  while (up)
-    {
-    result = up->GetInternal(key);
-    if(result.second)
-      {
-      break;
-      }
-    ups.push_back(up);
-    up = up->Up;
-    }
-  // Store the result in intermediate scopes.
-  for (std::list<cmDefinitions*>::const_iterator it = ups.begin();
-       it != ups.end(); ++it)
-    {
-    (*it)->Set(key, result.first);
-    }
-  return result.first;
+  return this->GetInternal(key);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index ef83e4a..b8f9fa3 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -23,8 +23,7 @@
  * \brief Store a scope of variable definitions for CMake language.
  *
  * This stores the state of variable definitions (set or unset) for
- * one scope.  Sets are always local.  Gets search parent scopes
- * transitively and save results locally.
+ * one scope.  Sets are always local.
  */
 class cmDefinitions
 {
@@ -35,9 +34,7 @@ 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);
+  std::pair<const char*, bool> Get(const std::string& key);
 
   /** Set (or unset if null) a value associated with a key.  */
   void Set(const std::string& key, const char* value);
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index a312f3d..9a9d53d 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -70,7 +70,23 @@ public:
 
   const char* GetDefinition(std::string const& name)
   {
-    return this->VarStack.back().Get(name);
+    std::pair<const char*, bool> result((const char*)0, false);
+    std::list<cmDefinitions>::reverse_iterator it = VarStack.rbegin();
+    for ( ; it != this->VarStack.rend(); ++it)
+      {
+      result = it->Get(name);
+      if(result.second)
+        {
+        break;
+        }
+      }
+    std::list<cmDefinitions>::reverse_iterator last = it;
+    // Store the result in intermediate scopes.
+    for (it = this->VarStack.rbegin(); it != last; ++it)
+      {
+      it->Set(name, result.first);
+      }
+    return result.first;
   }
 
   void SetDefinition(std::string const& name, std::string const& value)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ad831a56ec910ea06b44189d04d52a5f84518432
commit ad831a56ec910ea06b44189d04d52a5f84518432
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 16:22:52 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 00:32:49 2015 +0200

    cmMakefile: Implement RaiseScope in terms of local Get method.
    
    The cmDefinitions::Get will change behavior in follow up commits.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 79bea07..a312f3d 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -119,10 +119,8 @@ public:
   {
     if(this->VarStack.size() > 1)
       {
-      cmDefinitions& cur = this->VarStack.back();
-
       // First localize the definition in the current scope.
-      cur.Get(var);
+      this->GetDefinition(var);
 
       // Now update the definition in the parent scope.
       cmDefinitions& up = *(++this->VarStack.rbegin());

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=82a57e665bc22e6d5e74211210e35fa8c8238019
commit 82a57e665bc22e6d5e74211210e35fa8c8238019
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu Apr 30 00:19:55 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 00:32:49 2015 +0200

    cmMakefile: Implement RaiseScope without relying on Parent.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 1d3e496..79bea07 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -117,14 +117,16 @@ public:
 
   bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf)
   {
-    cmDefinitions& cur = this->VarStack.back();
-    if(cmDefinitions* up = cur.GetParent())
+    if(this->VarStack.size() > 1)
       {
+      cmDefinitions& cur = this->VarStack.back();
+
       // First localize the definition in the current scope.
       cur.Get(var);
 
       // Now update the definition in the parent scope.
-      up->Set(var, varDef);
+      cmDefinitions& up = *(++this->VarStack.rbegin());
+      up.Set(var, varDef);
       }
     else if(cmLocalGenerator* plg = mf->GetLocalGenerator()->GetParent())
       {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f9b42dc5964f040fff4682274a14f89ab3c0f36a
commit f9b42dc5964f040fff4682274a14f89ab3c0f36a
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 13:10:43 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 00:32:49 2015 +0200

    cmDefinitions: Extract loop from GetInternal to Get.
    
    Remove now-unused NoDef static member.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index c4b7437..10f780c 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -12,26 +12,34 @@
 #include "cmDefinitions.h"
 
 //----------------------------------------------------------------------------
-cmDefinitions::Def cmDefinitions::NoDef;
-
-//----------------------------------------------------------------------------
 cmDefinitions::cmDefinitions(cmDefinitions* parent)
   : Up(parent)
 {
 }
 
 //----------------------------------------------------------------------------
-const char* cmDefinitions::GetInternal(const std::string& key)
+std::pair<const char*, bool> cmDefinitions::GetInternal(const std::string& key)
+{
+  MapType::const_iterator i = this->Map.find(key);
+  std::pair<const char*, bool> result((const char*)0, false);
+  if(i != this->Map.end())
+    {
+    result = std::make_pair(i->second.Exists ? i->second.c_str() : 0, true);
+    }
+  return result;
+}
+
+//----------------------------------------------------------------------------
+const char* cmDefinitions::Get(const std::string& key)
 {
   std::list<cmDefinitions*> ups;
-  Def def = this->NoDef;
   cmDefinitions* up = this;
+  std::pair<const char*, bool> result((const char*)0, false);
   while (up)
     {
-    MapType::const_iterator i = up->Map.find(key);
-    if(i != up->Map.end())
+    result = up->GetInternal(key);
+    if(result.second)
       {
-      def = i->second;
       break;
       }
     ups.push_back(up);
@@ -41,15 +49,9 @@ const char* cmDefinitions::GetInternal(const std::string& key)
   for (std::list<cmDefinitions*>::const_iterator it = ups.begin();
        it != ups.end(); ++it)
     {
-    (*it)->Set(key, def.Exists? def.c_str() : 0);
+    (*it)->Set(key, result.first);
     }
-  return def.Exists? def.c_str() : 0;
-}
-
-//----------------------------------------------------------------------------
-const char* cmDefinitions::Get(const std::string& key)
-{
-  return this->GetInternal(key);
+  return result.first;
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 18c9737..ef83e4a 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -67,7 +67,6 @@ private:
     Def(Def const& d): std_string(d), Exists(d.Exists) {}
     bool Exists;
   };
-  static Def NoDef;
 
   // Parent scope, if any.
   cmDefinitions* Up;
@@ -81,7 +80,7 @@ private:
   MapType Map;
 
   // Internal query and update methods.
-  const char* GetInternal(const std::string& key);
+  std::pair<const char*, bool> GetInternal(const std::string& key);
 
   void MakeClosure(std::set<std::string>& undefined,
                    std::list<cmDefinitions>::const_reverse_iterator rbegin,

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2b9015cb45bae66fd368b61de2db6b2c7527b42e
commit 2b9015cb45bae66fd368b61de2db6b2c7527b42e
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 13:28:19 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 00:32:49 2015 +0200

    cmDefinitions: Use Set API in Get implementation.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 52f3412..c4b7437 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -41,7 +41,7 @@ const char* cmDefinitions::GetInternal(const std::string& key)
   for (std::list<cmDefinitions*>::const_iterator it = ups.begin();
        it != ups.end(); ++it)
     {
-    (*it)->Map[key] = def;
+    (*it)->Set(key, def.Exists? def.c_str() : 0);
     }
   return def.Exists? def.c_str() : 0;
 }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=825a44b30443e42495606357f677b4fa70e0e6f9
commit 825a44b30443e42495606357f677b4fa70e0e6f9
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:09:11 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 00:32:48 2015 +0200

    cmDefinitions: Use map::operator[] in Get.
    
    The key is not already in the map.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index b6e3dd5..52f3412 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -41,7 +41,7 @@ const char* cmDefinitions::GetInternal(const std::string& key)
   for (std::list<cmDefinitions*>::const_iterator it = ups.begin();
        it != ups.end(); ++it)
     {
-    (*it)->Map.insert(MapType::value_type(key, def));
+    (*it)->Map[key] = def;
     }
   return def.Exists? def.c_str() : 0;
 }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=33a9cb0a05844f295dc0ba840febc21cbdd082ee
commit 33a9cb0a05844f295dc0ba840febc21cbdd082ee
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 13:02:25 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 00:32:48 2015 +0200

    cmDefinitions: Simplify API of GetInternal.
    
    Remove need to keep iterator over loops.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index e623581..b6e3dd5 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -21,16 +21,14 @@ cmDefinitions::cmDefinitions(cmDefinitions* parent)
 }
 
 //----------------------------------------------------------------------------
-cmDefinitions::Def const&
-cmDefinitions::GetInternal(const std::string& key)
+const char* cmDefinitions::GetInternal(const std::string& key)
 {
   std::list<cmDefinitions*> ups;
   Def def = this->NoDef;
-  MapType::const_iterator i;
   cmDefinitions* up = this;
   while (up)
     {
-    i = up->Map.find(key);
+    MapType::const_iterator i = up->Map.find(key);
     if(i != up->Map.end())
       {
       def = i->second;
@@ -43,16 +41,15 @@ cmDefinitions::GetInternal(const std::string& key)
   for (std::list<cmDefinitions*>::const_iterator it = ups.begin();
        it != ups.end(); ++it)
     {
-    i = (*it)->Map.insert(MapType::value_type(key, def)).first;
+    (*it)->Map.insert(MapType::value_type(key, def));
     }
-  return i->second;
+  return def.Exists? def.c_str() : 0;
 }
 
 //----------------------------------------------------------------------------
 const char* cmDefinitions::Get(const std::string& key)
 {
-  Def const& def = this->GetInternal(key);
-  return def.Exists? def.c_str() : 0;
+  return this->GetInternal(key);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 4c7f11f..18c9737 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -81,7 +81,7 @@ private:
   MapType Map;
 
   // Internal query and update methods.
-  Def const& GetInternal(const std::string& key);
+  const char* GetInternal(const std::string& key);
 
   void MakeClosure(std::set<std::string>& undefined,
                    std::list<cmDefinitions>::const_reverse_iterator rbegin,

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=15cfac49a65ae7d22855951bf5824b3541255128
commit 15cfac49a65ae7d22855951bf5824b3541255128
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 12:48:43 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 00:32:48 2015 +0200

    cmDefinitions: Remove conditionals before loop.
    
    They are now redundant.
    
    In the previous code, we knew that this->Map did not contain the
    searched value, so we stored 'this' in the ups list.  Now we don't
    know that prior to the loop.  Only cmDefinitions which do not
    contain the value should be in the ups list.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index af7be90..e623581 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -24,19 +24,10 @@ cmDefinitions::cmDefinitions(cmDefinitions* parent)
 cmDefinitions::Def const&
 cmDefinitions::GetInternal(const std::string& key)
 {
-  MapType::const_iterator i = this->Map.find(key);
-  if(i != this->Map.end())
-    {
-    return i->second;
-    }
-  cmDefinitions* up = this->Up;
-  if(!up)
-    {
-    return this->NoDef;
-    }
   std::list<cmDefinitions*> ups;
-  ups.push_back(this);
   Def def = this->NoDef;
+  MapType::const_iterator i;
+  cmDefinitions* up = this;
   while (up)
     {
     i = up->Map.find(key);

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5643d935bd5851d42982cc18cc1f6851dc80251b
commit 5643d935bd5851d42982cc18cc1f6851dc80251b
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 12:19:42 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 00:32:48 2015 +0200

    cmDefinitions: Replace GetInternal recursion with looping.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 61328be..af7be90 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -34,9 +34,27 @@ cmDefinitions::GetInternal(const std::string& key)
     {
     return this->NoDef;
     }
-  // 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;
+  std::list<cmDefinitions*> ups;
+  ups.push_back(this);
+  Def def = this->NoDef;
+  while (up)
+    {
+    i = up->Map.find(key);
+    if(i != up->Map.end())
+      {
+      def = i->second;
+      break;
+      }
+    ups.push_back(up);
+    up = up->Up;
+    }
+  // Store the result in intermediate scopes.
+  for (std::list<cmDefinitions*>::const_iterator it = ups.begin();
+       it != ups.end(); ++it)
+    {
+    i = (*it)->Map.insert(MapType::value_type(key, def)).first;
+    }
+  return i->second;
 }
 
 //----------------------------------------------------------------------------

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b48ea26a9d3b4384874554fe64edfce8784a9255
commit b48ea26a9d3b4384874554fe64edfce8784a9255
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 12:39:53 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Apr 30 00:32:48 2015 +0200

    cmDefinitions: Invert conditional code.
    
    Return the simple case first.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 115e30a..61328be 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -29,13 +29,14 @@ cmDefinitions::GetInternal(const std::string& key)
     {
     return i->second;
     }
-  if(cmDefinitions* up = this->Up)
+  cmDefinitions* up = this->Up;
+  if(!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;
+    return this->NoDef;
     }
-  return this->NoDef;
+  // 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;
 }
 
 //----------------------------------------------------------------------------

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

Summary of changes:
 Source/cmDefinitions.cxx |   30 ++++--------------------------
 Source/cmDefinitions.h   |   20 ++------------------
 Source/cmMakefile.cxx    |   33 ++++++++++++++++++++++-----------
 3 files changed, 28 insertions(+), 55 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list