[Cmake-commits] CMake branch, next, updated. v3.2.2-2196-g5a3b315

Stephen Kelly steveire at gmail.com
Sun Apr 26 16:07:20 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  5a3b315a23b15ec8931c171b396ed105a8a39976 (commit)
       via  197dbea197de129985c36e437abc9859f1ba548e (commit)
       via  7b95ef47de833ac42d76d25a6178eec26483066c (commit)
       via  d567d870970a35bf121da65b72d0609849cecf07 (commit)
       via  72850cad141d9c09d88d5607ad4a2a49efa5f8c9 (commit)
       via  427efac01fe082ae1ddb9796f45d8279e9bd6030 (commit)
       via  6624bee036f4230d85f7414fe85e51f5f93461d7 (commit)
       via  3c176ea14c25cdca0fc13e0922c88a1e48860970 (commit)
       via  1e627f63cb1dbee8dc32e5c3040c0c631e613cbd (commit)
       via  b54646bef25c1772a0bc0743de633cad2bce40e6 (commit)
      from  0228a6dd0e23c3932843b9bd417837b964d4cbf1 (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=5a3b315a23b15ec8931c171b396ed105a8a39976
commit 5a3b315a23b15ec8931c171b396ed105a8a39976
Merge: 0228a6d 197dbea
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 16:07:19 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sun Apr 26 16:07:19 2015 -0400

    Merge topic 'refactor-cmDefinitions' into next
    
    197dbea1 cmMakefile: Simplify the implementation of GetDefintion.
    7b95ef47 cmMakefile: Store definition stack as a vector.
    d567d870 cmDefinitions: Remove Parent pointer.
    72850cad cmDefinitions: Convert MakeClosure into a static method.
    427efac0 cmDefinitions: Implement MakeClosure in terms of a vector of ancestors.
    6624bee0 cmDefinitions: Use vector of cmDefinitions* to create closure.
    3c176ea1 cmDefinitions: Replace recursion with loop.
    1e627f63 cmDefinitions: Replace private constructor with MakeClosure.
    b54646be cmDefinitions: Externalize looping for ClosureKeys.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=197dbea197de129985c36e437abc9859f1ba548e
commit 197dbea197de129985c36e437abc9859f1ba548e
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 21:42:23 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 22:06:59 2015 +0200

    cmMakefile: Simplify the implementation of GetDefintion.
    
    No need to create an intermediate vector anymore.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index c51984b..d169765 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -70,28 +70,21 @@ public:
 
   const char* GetDefinition(std::string const& name)
   {
-    std::vector<cmDefinitions*> defPtrs;
-    defPtrs.reserve(this->VarStack.size());
-    for (std::vector<cmDefinitions>::iterator it = this->VarStack.begin();
-        it != this->VarStack.end(); ++it)
-      {
-      defPtrs.push_back(&*it);
-      }
     std::pair<const char*, bool> result((const char*)0, false);
-    std::vector<cmDefinitions*>::reverse_iterator it = defPtrs.rbegin();
-    for ( ; it != defPtrs.rend(); ++it)
+    std::vector<cmDefinitions>::reverse_iterator it = this->VarStack.rbegin();
+    for ( ; it != this->VarStack.rend(); ++it)
       {
-      result = (*it)->Get(name);
+      result = it->Get(name);
       if(result.second)
         {
         break;
         }
       }
-    std::vector<cmDefinitions*>::reverse_iterator last = it;
+    std::vector<cmDefinitions>::reverse_iterator last = it;
     // Store the result in intermediate scopes.
-    for (it = defPtrs.rbegin(); it != last; ++it)
+    for (it = this->VarStack.rbegin(); it != last; ++it)
       {
-      (*it)->Set(name, result.first);
+      it->Set(name, result.first);
       }
     return result.first;
   }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7b95ef47de833ac42d76d25a6178eec26483066c
commit 7b95ef47de833ac42d76d25a6178eec26483066c
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 16:22:52 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 22:06:58 2015 +0200

    cmMakefile: Store definition stack as a vector.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index ab1ee00..c51984b 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -38,30 +38,28 @@
 #include <cmsys/FStream.hxx>
 #include <cmsys/auto_ptr.hxx>
 
-#include <list>
 #include <ctype.h> // for isspace
 #include <assert.h>
 
 class cmMakefile::Internals
 {
 public:
-  std::list<cmDefinitions> VarStack;
+  std::vector<cmDefinitions> VarStack;
   std::stack<std::set<std::string> > VarInitStack;
   std::stack<std::set<std::string> > VarUsageStack;
   bool IsSourceFileTryCompile;
 
   void PushDefinitions()
   {
-    this->VarStack.push_back(cmDefinitions());
+    this->VarStack.resize(this->VarStack.size() + 1);
   }
 
   void InitializeDefinitions(cmMakefile* parent)
   {
     std::vector<cmDefinitions const*> defPtrs;
-    defPtrs.reserve(this->VarStack.size());
-    for (std::list<cmDefinitions>::iterator it =
-         parent->Internal->VarStack.begin();
-         it != parent->Internal->VarStack.end(); ++it)
+    for (std::vector<cmDefinitions>::iterator it =
+        parent->Internal->VarStack.begin();
+        it != parent->Internal->VarStack.end(); ++it)
       {
       defPtrs.push_back(&*it);
       }
@@ -74,7 +72,7 @@ public:
   {
     std::vector<cmDefinitions*> defPtrs;
     defPtrs.reserve(this->VarStack.size());
-    for (std::list<cmDefinitions>::iterator it = this->VarStack.begin();
+    for (std::vector<cmDefinitions>::iterator it = this->VarStack.begin();
         it != this->VarStack.end(); ++it)
       {
       defPtrs.push_back(&*it);
@@ -125,7 +123,7 @@ public:
   {
     std::vector<std::string> closureKeys;
     std::vector<std::string> undefinedKeys;
-    for (std::list<cmDefinitions>::const_iterator it = this->VarStack.begin();
+    for (std::vector<cmDefinitions>::const_iterator it = this->VarStack.begin();
         it != this->VarStack.end(); ++it)
       {
       std::vector<std::string> const& localKeys = it->Keys(undefinedKeys);
@@ -146,14 +144,14 @@ 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)
       {
       // First localize the definition in the current scope.
-      cur.Get(var);
+      this->GetDefinition(var);
 
       // Now update the definition in the parent scope.
-      up->Set(var, varDef);
+      cmDefinitions& up = this->VarStack[this->VarStack.size() - 2];
+      up.Set(var, varDef);
       }
     else if(cmLocalGenerator* plg = mf->GetLocalGenerator()->GetParent())
       {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d567d870970a35bf121da65b72d0609849cecf07
commit d567d870970a35bf121da65b72d0609849cecf07
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 16:19:11 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 22:06:58 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 b537729..bf517e3 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -14,12 +14,6 @@
 #include <assert.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 5a3a993..6c57c36 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -26,12 +26,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.  */
@@ -63,9 +57,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 299b4c9..ab1ee00 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -52,12 +52,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=72850cad141d9c09d88d5607ad4a2a49efa5f8c9
commit 72850cad141d9c09d88d5607ad4a2a49efa5f8c9
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 16:13:56 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 22:06:58 2015 +0200

    cmDefinitions: Convert MakeClosure into a static method.
    
    Accept a range of cmDefinitions*.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 25dd582..b537729 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -61,18 +61,13 @@ std::vector<std::string> cmDefinitions::LocalKeys() const
 }
 
 //----------------------------------------------------------------------------
-cmDefinitions cmDefinitions::MakeClosure() const
+cmDefinitions cmDefinitions::MakeClosure(
+    std::vector<cmDefinitions const*>::iterator begin,
+    std::vector<cmDefinitions const*>::iterator end)
 {
   std::set<std::string> undefined;
   cmDefinitions closure;
-  cmDefinitions const* defs = this;
-  std::vector<cmDefinitions const*> ups;
-  while(defs)
-    {
-    ups.push_back(defs);
-    defs = defs->Up;
-    }
-  closure.MakeClosure(undefined, ups.begin(), ups.end());
+  closure.MakeClosure(undefined, begin, end);
   return closure;
 }
 
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index f2c014f..5a3a993 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -45,7 +45,9 @@ public:
   std::vector<std::string>
   Keys(std::vector<std::string>& undefinedKeys) const;
 
-  cmDefinitions MakeClosure() const;
+  static cmDefinitions MakeClosure(
+      std::vector<cmDefinitions const*>::iterator begin,
+      std::vector<cmDefinitions const*>::iterator end);
 
 private:
   // String with existence boolean.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 36e06f5..299b4c9 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -62,7 +62,17 @@ public:
 
   void InitializeDefinitions(cmMakefile* parent)
   {
-    this->VarStack.back() = parent->Internal->VarStack.back().MakeClosure();
+    std::vector<cmDefinitions const*> defPtrs;
+    defPtrs.reserve(this->VarStack.size());
+    for (std::list<cmDefinitions>::iterator it =
+         parent->Internal->VarStack.begin();
+         it != parent->Internal->VarStack.end(); ++it)
+      {
+      defPtrs.push_back(&*it);
+      }
+    std::reverse(defPtrs.begin(), defPtrs.end());
+    this->VarStack.back() = cmDefinitions::MakeClosure(defPtrs.begin(),
+                                                       defPtrs.end());
   }
 
   const char* GetDefinition(std::string const& name)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=427efac01fe082ae1ddb9796f45d8279e9bd6030
commit 427efac01fe082ae1ddb9796f45d8279e9bd6030
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 16:00:18 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 22:06:58 2015 +0200

    cmDefinitions: Implement MakeClosure in terms of a vector of ancestors.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 2b80347..25dd582 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -65,22 +65,25 @@ cmDefinitions cmDefinitions::MakeClosure() const
 {
   std::set<std::string> undefined;
   cmDefinitions closure;
-  closure.MakeClosure(undefined, this);
-  return closure;
-}
-
-//----------------------------------------------------------------------------
-void cmDefinitions::MakeClosure(std::set<std::string>& undefined,
-                                cmDefinitions const* defs)
-{
-  std::vector<cmDefinitions*> ups;
+  cmDefinitions const* defs = this;
+  std::vector<cmDefinitions const*> ups;
   while(defs)
     {
     ups.push_back(defs);
     defs = defs->Up;
     }
-  for (std::vector<cmDefinitions*>::const_iterator it = ups.begin();
-       it != ups.end(); ++it)
+  closure.MakeClosure(undefined, ups.begin(), ups.end());
+  return closure;
+}
+
+//----------------------------------------------------------------------------
+void
+cmDefinitions::MakeClosure(std::set<std::string>& undefined,
+                           std::vector<cmDefinitions const*>::iterator begin,
+                           std::vector<cmDefinitions const*>::iterator end)
+{
+  for (std::vector<cmDefinitions const*>::const_iterator it = begin;
+       it != end; ++it)
     {
     // Consider local definitions.
     for(MapType::const_iterator mi = (*it)->Map.begin();
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index dcfb01d..f2c014f 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -73,7 +73,8 @@ private:
   MapType Map;
 
   void MakeClosure(std::set<std::string>& undefined,
-                   cmDefinitions const* defs);
+                   std::vector<cmDefinitions const*>::iterator begin,
+                   std::vector<cmDefinitions const*>::iterator end);
 };
 
 #endif

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6624bee036f4230d85f7414fe85e51f5f93461d7
commit 6624bee036f4230d85f7414fe85e51f5f93461d7
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:54:02 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 22:06:57 2015 +0200

    cmDefinitions: Use vector of cmDefinitions* to create closure.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index a130900..2b80347 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -73,11 +73,18 @@ cmDefinitions cmDefinitions::MakeClosure() const
 void cmDefinitions::MakeClosure(std::set<std::string>& undefined,
                                 cmDefinitions const* defs)
 {
+  std::vector<cmDefinitions*> ups;
   while(defs)
     {
+    ups.push_back(defs);
+    defs = defs->Up;
+    }
+  for (std::vector<cmDefinitions*>::const_iterator it = ups.begin();
+       it != ups.end(); ++it)
+    {
     // Consider local definitions.
-    for(MapType::const_iterator mi = defs->Map.begin();
-        mi != defs->Map.end(); ++mi)
+    for(MapType::const_iterator mi = (*it)->Map.begin();
+        mi != (*it)->Map.end(); ++mi)
       {
       // Use this key if it is not already set or unset.
       if(this->Map.find(mi->first) == this->Map.end() &&
@@ -93,7 +100,6 @@ void cmDefinitions::MakeClosure(std::set<std::string>& undefined,
           }
         }
       }
-    defs = defs->Up;
     }
 }
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3c176ea14c25cdca0fc13e0922c88a1e48860970
commit 3c176ea14c25cdca0fc13e0922c88a1e48860970
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:49:43 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 22:06:57 2015 +0200

    cmDefinitions: Replace recursion with loop.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 5381ab8..a130900 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -73,29 +73,27 @@ cmDefinitions cmDefinitions::MakeClosure() const
 void cmDefinitions::MakeClosure(std::set<std::string>& undefined,
                                 cmDefinitions const* defs)
 {
-  // Consider local definitions.
-  for(MapType::const_iterator mi = defs->Map.begin();
-      mi != defs->Map.end(); ++mi)
+  while(defs)
     {
-    // Use this key if it is not already set or unset.
-    if(this->Map.find(mi->first) == this->Map.end() &&
-       undefined.find(mi->first) == undefined.end())
+    // Consider local definitions.
+    for(MapType::const_iterator mi = defs->Map.begin();
+        mi != defs->Map.end(); ++mi)
       {
-      if(mi->second.Exists)
-        {
-        this->Map.insert(*mi);
-        }
-      else
+      // Use this key if it is not already set or unset.
+      if(this->Map.find(mi->first) == this->Map.end() &&
+         undefined.find(mi->first) == undefined.end())
         {
-        undefined.insert(mi->first);
+        if(mi->second.Exists)
+          {
+          this->Map.insert(*mi);
+          }
+        else
+          {
+          undefined.insert(mi->first);
+          }
         }
       }
-    }
-
-  // Traverse parents.
-  if(cmDefinitions const* up = defs->Up)
-    {
-    this->MakeClosure(undefined, up);
+    defs = defs->Up;
     }
 }
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1e627f63cb1dbee8dc32e5c3040c0c631e613cbd
commit 1e627f63cb1dbee8dc32e5c3040c0c631e613cbd
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:44:26 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 22:06:57 2015 +0200

    cmDefinitions: Replace private constructor with MakeClosure.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index ffc65e9..5381ab8 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -61,21 +61,16 @@ std::vector<std::string> cmDefinitions::LocalKeys() const
 }
 
 //----------------------------------------------------------------------------
-cmDefinitions cmDefinitions::Closure() const
-{
-  return cmDefinitions(ClosureTag(), this);
-}
-
-//----------------------------------------------------------------------------
-cmDefinitions::cmDefinitions(ClosureTag const&, cmDefinitions const* root):
-  Up(0)
+cmDefinitions cmDefinitions::MakeClosure() const
 {
   std::set<std::string> undefined;
-  this->ClosureImpl(undefined, root);
+  cmDefinitions closure;
+  closure.MakeClosure(undefined, this);
+  return closure;
 }
 
 //----------------------------------------------------------------------------
-void cmDefinitions::ClosureImpl(std::set<std::string>& undefined,
+void cmDefinitions::MakeClosure(std::set<std::string>& undefined,
                                 cmDefinitions const* defs)
 {
   // Consider local definitions.
@@ -100,7 +95,7 @@ void cmDefinitions::ClosureImpl(std::set<std::string>& undefined,
   // Traverse parents.
   if(cmDefinitions const* up = defs->Up)
     {
-    this->ClosureImpl(undefined, up);
+    this->MakeClosure(undefined, up);
     }
 }
 
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index e79614a..dcfb01d 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -42,13 +42,11 @@ public:
   /** Get the set of all local keys.  */
   std::vector<std::string> LocalKeys() const;
 
-  /** Compute the closure of all defined keys with values.
-      This flattens the scope.  The result has no parent.  */
-  cmDefinitions Closure() const;
-
   std::vector<std::string>
   Keys(std::vector<std::string>& undefinedKeys) const;
 
+  cmDefinitions MakeClosure() const;
+
 private:
   // String with existence boolean.
   struct Def: public std::string
@@ -74,10 +72,7 @@ private:
 #endif
   MapType Map;
 
-  // Implementation of Closure() method.
-  struct ClosureTag {};
-  cmDefinitions(ClosureTag const&, cmDefinitions const* root);
-  void ClosureImpl(std::set<std::string>& undefined,
+  void MakeClosure(std::set<std::string>& undefined,
                    cmDefinitions const* defs);
 };
 
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index b95dfe2..36e06f5 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -62,7 +62,7 @@ public:
 
   void InitializeDefinitions(cmMakefile* parent)
   {
-    this->VarStack.back() = parent->Internal->VarStack.back().Closure();
+    this->VarStack.back() = parent->Internal->VarStack.back().MakeClosure();
   }
 
   const char* GetDefinition(std::string const& name)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b54646bef25c1772a0bc0743de633cad2bce40e6
commit b54646bef25c1772a0bc0743de633cad2bce40e6
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:38:36 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 22:06:56 2015 +0200

    cmDefinitions: Externalize looping for ClosureKeys.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index d612a63..ffc65e9 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -105,28 +105,20 @@ void cmDefinitions::ClosureImpl(std::set<std::string>& undefined,
 }
 
 //----------------------------------------------------------------------------
-std::vector<std::string> cmDefinitions::ClosureKeys() const
+std::vector<std::string>
+cmDefinitions::Keys(std::vector<std::string>& undefined) const
 {
-  std::set<std::string> defined;
-  std::set<std::string> undefined;
-
-  cmDefinitions const* up = this;
-
-  while (up)
+  std::vector<std::string> defined;
+  defined.reserve(this->Map.size());
+  for(MapType::const_iterator mi = this->Map.begin();
+      mi != this->Map.end(); ++mi)
     {
-    // Consider local definitions.
-    for(MapType::const_iterator mi = up->Map.begin();
-        mi != up->Map.end(); ++mi)
-      {
-      // Use this key if it is not already set or unset.
-      if(defined.find(mi->first) == defined.end() &&
-         undefined.find(mi->first) == undefined.end())
-        {
-        std::set<std::string>& m = mi->second.Exists? defined : undefined;
-        m.insert(mi->first);
-        }
-      }
-    up = this->Up;
+    std::vector<std::string>& m = mi->second.Exists? defined : undefined;
+    m.push_back(mi->first);
     }
-  return std::vector<std::string>(defined.begin(), defined.end());
+  std::sort(defined.begin(), defined.end());
+  std::sort(undefined.begin(), undefined.end());
+  undefined.erase(std::unique(undefined.begin(), undefined.end()),
+                  undefined.end());
+  return defined;
 }
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index c3644bb..e79614a 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -46,8 +46,8 @@ public:
       This flattens the scope.  The result has no parent.  */
   cmDefinitions Closure() const;
 
-  /** Compute the set of all defined keys.  */
-  std::vector<std::string> ClosureKeys() const;
+  std::vector<std::string>
+  Keys(std::vector<std::string>& undefinedKeys) const;
 
 private:
   // String with existence boolean.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 332c52b..b95dfe2 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -118,7 +118,20 @@ public:
 
   std::vector<std::string> ClosureKeys() const
   {
-    return this->VarStack.back().ClosureKeys();
+    std::vector<std::string> closureKeys;
+    std::vector<std::string> undefinedKeys;
+    for (std::list<cmDefinitions>::const_iterator it = this->VarStack.begin();
+        it != this->VarStack.end(); ++it)
+      {
+      std::vector<std::string> const& localKeys = it->Keys(undefinedKeys);
+      closureKeys.insert(closureKeys.end(), localKeys.begin(), localKeys.end());
+      std::vector<std::string>::iterator newIt =
+          closureKeys.end() - localKeys.size();
+      std::inplace_merge(closureKeys.begin(), newIt, closureKeys.end());
+      }
+    closureKeys.erase(std::unique(closureKeys.begin(),
+                                  closureKeys.end()), closureKeys.end());
+    return closureKeys;
   }
 
   void PopDefinitions()

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

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list