[Cmake-commits] CMake branch, next, updated. v3.2.2-2218-g6ae042c

Stephen Kelly steveire at gmail.com
Mon Apr 27 15:44:55 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  6ae042cffd8dde1990c8bfeefa8e89da511dca97 (commit)
       via  873361c4ae6fc6a613f1c0d67f3e98b7a94d4747 (commit)
       via  00af25c1c9add116a97c06dac99cc3322cbd79f9 (commit)
       via  8b139e3762969c32ab404e39747f595eb32b50b7 (commit)
       via  8e92d35428215626b5a843d49d8e8c8c95d66428 (commit)
       via  ec0ac939c727a273e7e1ef324e061c52bea45d30 (commit)
       via  fc0bb19c3bab1212749b492fa85c916b32f0ff43 (commit)
       via  2ffcac556b9c8dc9f8d4c3fed42ab4d254de0601 (commit)
       via  693394fffb494d3c11004a4b6326ff4c483702a3 (commit)
       via  97dd34d83a86e689b44bee58ebb19d80dabcd507 (commit)
      from  258e711e9bc68bd745ec01aefe5e0ae98b493c11 (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=6ae042cffd8dde1990c8bfeefa8e89da511dca97
commit 6ae042cffd8dde1990c8bfeefa8e89da511dca97
Merge: 258e711 873361c
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Mon Apr 27 15:44:54 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Apr 27 15:44:54 2015 -0400

    Merge topic 'refactor-cmDefinitions' into next
    
    873361c4 cmMakefile: Simplify the implementation of GetDefintion.
    00af25c1 cmMakefile: Store definition stack as a vector.
    8b139e37 cmDefinitions: Remove Parent pointer.
    8e92d354 cmDefinitions: Convert MakeClosure into a static method.
    ec0ac939 cmDefinitions: Implement MakeClosure in terms of a vector of ancestors.
    fc0bb19c cmDefinitions: Use vector of cmDefinitions* to create closure.
    2ffcac55 cmDefinitions: Replace recursion with loop.
    693394ff cmDefinitions: Replace private constructor with MakeClosure.
    97dd34d8 cmDefinitions: Externalize looping for ClosureKeys.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=873361c4ae6fc6a613f1c0d67f3e98b7a94d4747
commit 873361c4ae6fc6a613f1c0d67f3e98b7a94d4747
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 21:42:23 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon Apr 27 21:44:01 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 8a4aaec..b46c99f 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=00af25c1c9add116a97c06dac99cc3322cbd79f9
commit 00af25c1c9add116a97c06dac99cc3322cbd79f9
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 16:22:52 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon Apr 27 21:44:01 2015 +0200

    cmMakefile: Store definition stack as a vector.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 0361157..8a4aaec 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,8 +123,8 @@ public:
   {
     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)
+    for (std::vector<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(),
@@ -147,14 +145,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=8b139e3762969c32ab404e39747f595eb32b50b7
commit 8b139e3762969c32ab404e39747f595eb32b50b7
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 16:19:11 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon Apr 27 21:44:00 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 d1a102d..0361157 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=8e92d35428215626b5a843d49d8e8c8c95d66428
commit 8e92d35428215626b5a843d49d8e8c8c95d66428
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 16:13:56 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon Apr 27 21:44:00 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 4b3197b..d1a102d 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=ec0ac939c727a273e7e1ef324e061c52bea45d30
commit ec0ac939c727a273e7e1ef324e061c52bea45d30
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 16:00:18 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon Apr 27 21:44:00 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=fc0bb19c3bab1212749b492fa85c916b32f0ff43
commit fc0bb19c3bab1212749b492fa85c916b32f0ff43
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:54:02 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon Apr 27 21:44:00 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=2ffcac556b9c8dc9f8d4c3fed42ab4d254de0601
commit 2ffcac556b9c8dc9f8d4c3fed42ab4d254de0601
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:49:43 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon Apr 27 21:44:00 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=693394fffb494d3c11004a4b6326ff4c483702a3
commit 693394fffb494d3c11004a4b6326ff4c483702a3
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:44:26 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon Apr 27 21:43:59 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 7fd5473..4b3197b 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=97dd34d83a86e689b44bee58ebb19d80dabcd507
commit 97dd34d83a86e689b44bee58ebb19d80dabcd507
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:38:36 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon Apr 27 21:43:59 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..7fd5473 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -118,7 +118,21 @@ 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