[Cmake-commits] CMake branch, next, updated. v3.2.2-2149-g917db9c
Stephen Kelly
steveire at gmail.com
Sun Apr 26 13:19:41 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 917db9c4c4eaa791db8861de2ace7f3263c80f0a (commit)
via f6dd5e51bf05300b7a92174b8e0cd816915fdec5 (commit)
via e7047346d3bdb2a2b8bc6e3c20c29ffe21186e84 (commit)
via e30b79bd5f1e5b9ae5ee8f7fe7caed624589b938 (commit)
via 95779974d68a2dacf1e56f5de4d247a4a69ad6de (commit)
via 87ef1f52ddb39f677f9a0c3d8cf8056758238674 (commit)
via 78be95e044acad5f2033b966b7869885bc33c27c (commit)
via d8036f07093ba2a54b34ba52069e1055c1f9bb47 (commit)
via bd7dce6e5e76f587a9ae5b0604fb68ea22f2dd51 (commit)
via 6b56f353b81139f4915d6a1ee2a02e81922ee8d4 (commit)
via a7d01d7af467b032945ba6fe2672d2724e24a573 (commit)
via 7ee00868d7e34f14d9569c6ad333d35e37483a85 (commit)
via 1455f3f4208f0dc842c933039a07603da30a5255 (commit)
via 33eeaca3628f3c9834de6d99d3ba9323def06d01 (commit)
via 9ac77765d1e870d4015cf7e084bd33889b50590b (commit)
from 852da24c1c77e54a8ae95dcc264461f94a314f3a (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=917db9c4c4eaa791db8861de2ace7f3263c80f0a
commit 917db9c4c4eaa791db8861de2ace7f3263c80f0a
Merge: 852da24 f6dd5e5
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 13:19:39 2015 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sun Apr 26 13:19:39 2015 -0400
Merge topic 'refactor-cmDefinitions' into next
f6dd5e51 cmMakefile: Store definition stack as a vector.
e7047346 cmDefinitions: Remove Parent pointer.
e30b79bd cmDefinitions: Convert MakeClosure into a static method.
95779974 cmDefinitions: Implement MakeClosure in terms of a vector of ancestors.
87ef1f52 cmDefinitions: Use vector of cmDefinitions* to create closure.
78be95e0 cmDefinitions: Replace recursion with loop.
d8036f07 cmDefinitions: Replace private constructor with MakeClosure.
bd7dce6e cmDefinitions: Externalize looping for ClosureKeys.
6b56f353 cmDefinitions: Change LocalKeys to return a vector.
a7d01d7a cmDefinitions: Make ClosureKeys API vector-based.
7ee00868 cmDefinitions: Inline GetClosureKeys implementation.
1455f3f4 cmDefinitions: Replace ClosureKeys recursion with looping.
33eeaca3 cmDefinitions: Inline GetInternal into Get.
9ac77765 cmDefinitions: Externalize the stack loop for the Get method.
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f6dd5e51bf05300b7a92174b8e0cd816915fdec5
commit f6dd5e51bf05300b7a92174b8e0cd816915fdec5
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 19:18:36 2015 +0200
cmMakefile: Store definition stack as a vector.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 0acb486..a124105 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -46,23 +46,21 @@
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);
}
@@ -75,7 +73,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);
@@ -126,7 +124,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);
@@ -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=e7047346d3bdb2a2b8bc6e3c20c29ffe21186e84
commit e7047346d3bdb2a2b8bc6e3c20c29ffe21186e84
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 19:18:34 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 fe27b76..a39855f 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 7362ec4..0acb486 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=e30b79bd5f1e5b9ae5ee8f7fe7caed624589b938
commit e30b79bd5f1e5b9ae5ee8f7fe7caed624589b938
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 19:18:22 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 8613ea9..fe27b76 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 a68a05a..7362ec4 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -63,7 +63,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=95779974d68a2dacf1e56f5de4d247a4a69ad6de
commit 95779974d68a2dacf1e56f5de4d247a4a69ad6de
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 19:18:22 2015 +0200
cmDefinitions: Implement MakeClosure in terms of a vector of ancestors.
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index d9f28f0..8613ea9 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=87ef1f52ddb39f677f9a0c3d8cf8056758238674
commit 87ef1f52ddb39f677f9a0c3d8cf8056758238674
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 19:18:22 2015 +0200
cmDefinitions: Use vector of cmDefinitions* to create closure.
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 988d28b..d9f28f0 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=78be95e044acad5f2033b966b7869885bc33c27c
commit 78be95e044acad5f2033b966b7869885bc33c27c
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 19:18:22 2015 +0200
cmDefinitions: Replace recursion with loop.
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 94b27fd..988d28b 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=d8036f07093ba2a54b34ba52069e1055c1f9bb47
commit d8036f07093ba2a54b34ba52069e1055c1f9bb47
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 19:18:21 2015 +0200
cmDefinitions: Replace private constructor with MakeClosure.
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 844d72b..94b27fd 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 0a2119c..a68a05a 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -63,7 +63,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=bd7dce6e5e76f587a9ae5b0604fb68ea22f2dd51
commit bd7dce6e5e76f587a9ae5b0604fb68ea22f2dd51
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 19:18:21 2015 +0200
cmDefinitions: Externalize looping for ClosureKeys.
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index d612a63..844d72b 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -105,28 +105,19 @@ 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(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 526e8b4..0a2119c 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -119,7 +119,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()
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6b56f353b81139f4915d6a1ee2a02e81922ee8d4
commit 6b56f353b81139f4915d6a1ee2a02e81922ee8d4
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 16:34:13 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 19:18:21 2015 +0200
cmDefinitions: Change LocalKeys to return a vector.
This is more efficient and we lose nothing.
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 929a407..d612a63 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -44,16 +44,17 @@ void cmDefinitions::Erase(const std::string& key)
}
//----------------------------------------------------------------------------
-std::set<std::string> cmDefinitions::LocalKeys() const
+std::vector<std::string> cmDefinitions::LocalKeys() const
{
- std::set<std::string> keys;
+ std::vector<std::string> keys;
+ keys.reserve(this->Map.size());
// Consider local definitions.
for(MapType::const_iterator mi = this->Map.begin();
mi != this->Map.end(); ++mi)
{
if (mi->second.Exists)
{
- keys.insert(mi->first);
+ keys.push_back(mi->first);
}
}
return keys;
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index e5a427f..c3644bb 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -40,7 +40,7 @@ public:
void Erase(const std::string& key);
/** Get the set of all local keys. */
- std::set<std::string> LocalKeys() const;
+ std::vector<std::string> LocalKeys() const;
/** Compute the closure of all defined keys with values.
This flattens the scope. The result has no parent. */
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 4f1eb51..526e8b4 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -112,7 +112,7 @@ public:
}
}
- std::set<std::string> LocalKeys() const
+ std::vector<std::string> LocalKeys() const
{
return this->VarStack.back().LocalKeys();
}
@@ -1906,8 +1906,8 @@ void cmMakefile::CheckForUnusedVariables() const
{
return;
}
- const std::set<std::string>& locals = this->Internal->LocalKeys();
- std::set<std::string>::const_iterator it = locals.begin();
+ const std::vector<std::string>& locals = this->Internal->LocalKeys();
+ std::vector<std::string>::const_iterator it = locals.begin();
for (; it != locals.end(); ++it)
{
this->CheckForUnused("out of scope", *it);
@@ -4458,10 +4458,10 @@ void cmMakefile::PopScope()
std::set<std::string> init = this->Internal->VarInitStack.top();
std::set<std::string> usage = this->Internal->VarUsageStack.top();
- const std::set<std::string>& locals = this->Internal->LocalKeys();
+ const std::vector<std::string>& locals = this->Internal->LocalKeys();
// Remove initialization and usage information for variables in the local
// scope.
- std::set<std::string>::const_iterator it = locals.begin();
+ std::vector<std::string>::const_iterator it = locals.begin();
for (; it != locals.end(); ++it)
{
init.erase(*it);
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a7d01d7af467b032945ba6fe2672d2724e24a573
commit a7d01d7af467b032945ba6fe2672d2724e24a573
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:36:49 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 19:18:21 2015 +0200
cmDefinitions: Make ClosureKeys API vector-based.
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index bcb70e1..929a407 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -104,7 +104,7 @@ void cmDefinitions::ClosureImpl(std::set<std::string>& undefined,
}
//----------------------------------------------------------------------------
-std::set<std::string> cmDefinitions::ClosureKeys() const
+std::vector<std::string> cmDefinitions::ClosureKeys() const
{
std::set<std::string> defined;
std::set<std::string> undefined;
@@ -127,5 +127,5 @@ std::set<std::string> cmDefinitions::ClosureKeys() const
}
up = this->Up;
}
- return defined;
+ return std::vector<std::string>(defined.begin(), defined.end());
}
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 1a8d8e8..e5a427f 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -47,7 +47,7 @@ public:
cmDefinitions Closure() const;
/** Compute the set of all defined keys. */
- std::set<std::string> ClosureKeys() const;
+ std::vector<std::string> ClosureKeys() const;
private:
// String with existence boolean.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 827386e..4f1eb51 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -117,7 +117,7 @@ public:
return this->VarStack.back().LocalKeys();
}
- std::set<std::string> ClosureKeys() const
+ std::vector<std::string> ClosureKeys() const
{
return this->VarStack.back().ClosureKeys();
}
@@ -2519,8 +2519,7 @@ std::vector<std::string> cmMakefile
std::vector<std::string> res;
if ( !cacheonly )
{
- std::set<std::string> definitions = this->Internal->ClosureKeys();
- res.insert(res.end(), definitions.begin(), definitions.end());
+ res = this->Internal->ClosureKeys();
}
std::vector<std::string> cacheKeys =
this->GetState()->GetCacheEntryKeys();
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7ee00868d7e34f14d9569c6ad333d35e37483a85
commit 7ee00868d7e34f14d9569c6ad333d35e37483a85
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:38:09 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 19:18:20 2015 +0200
cmDefinitions: Inline GetClosureKeys implementation.
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index f6eddbc..bcb70e1 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -108,14 +108,7 @@ std::set<std::string> cmDefinitions::ClosureKeys() const
{
std::set<std::string> defined;
std::set<std::string> undefined;
- this->ClosureKeys(defined, undefined);
- return defined;
-}
-//----------------------------------------------------------------------------
-void cmDefinitions::ClosureKeys(std::set<std::string>& defined,
- std::set<std::string>& undefined) const
-{
cmDefinitions const* up = this;
while (up)
@@ -134,4 +127,5 @@ void cmDefinitions::ClosureKeys(std::set<std::string>& defined,
}
up = this->Up;
}
+ return defined;
}
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index f927c13..1a8d8e8 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -79,10 +79,6 @@ private:
cmDefinitions(ClosureTag const&, cmDefinitions const* root);
void ClosureImpl(std::set<std::string>& undefined,
cmDefinitions const* defs);
-
- // Implementation of ClosureKeys() method.
- void ClosureKeys(std::set<std::string>& defined,
- std::set<std::string>& undefined) const;
};
#endif
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1455f3f4208f0dc842c933039a07603da30a5255
commit 1455f3f4208f0dc842c933039a07603da30a5255
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 11:38:08 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 19:18:20 2015 +0200
cmDefinitions: Replace ClosureKeys recursion with looping.
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 83a6053..f6eddbc 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -116,22 +116,22 @@ std::set<std::string> cmDefinitions::ClosureKeys() const
void cmDefinitions::ClosureKeys(std::set<std::string>& defined,
std::set<std::string>& undefined) const
{
- // Consider local definitions.
- for(MapType::const_iterator mi = this->Map.begin();
- mi != this->Map.end(); ++mi)
+ cmDefinitions const* up = this;
+
+ while (up)
{
- // Use this key if it is not already set or unset.
- if(defined.find(mi->first) == defined.end() &&
- undefined.find(mi->first) == undefined.end())
+ // Consider local definitions.
+ for(MapType::const_iterator mi = up->Map.begin();
+ mi != up->Map.end(); ++mi)
{
- std::set<std::string>& m = mi->second.Exists? defined : undefined;
- m.insert(mi->first);
+ // 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);
+ }
}
- }
-
- // Traverse parents.
- if(cmDefinitions const* up = this->Up)
- {
- up->ClosureKeys(defined, undefined);
+ up = this->Up;
}
}
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=33eeaca3628f3c9834de6d99d3ba9323def06d01
commit 33eeaca3628f3c9834de6d99d3ba9323def06d01
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 15:08:30 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 19:18:20 2015 +0200
cmDefinitions: Inline GetInternal into Get.
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 899de1f..83a6053 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -20,7 +20,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);
@@ -32,12 +32,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 f4e35c5..f927c13 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -74,9 +74,6 @@ private:
#endif
MapType Map;
- // Internal query and update methods.
- std::pair<const char*, bool> GetInternal(const std::string& key);
-
// Implementation of Closure() method.
struct ClosureTag {};
cmDefinitions(ClosureTag const&, cmDefinitions const* root);
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9ac77765d1e870d4015cf7e084bd33889b50590b
commit 9ac77765d1e870d4015cf7e084bd33889b50590b
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Apr 26 13:10:43 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Apr 26 19:18:18 2015 +0200
cmDefinitions: Externalize the stack loop for the Get method.
Use a temporary vector to traverse the stack backwards.
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 6c7257e..899de1f 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -32,28 +32,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::vector<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::vector<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 a90c8ba..f4e35c5 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -21,8 +21,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
{
@@ -33,9 +32,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 7b7e3e0..827386e 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -68,7 +68,30 @@ public:
const char* GetDefinition(std::string const& name)
{
- return this->VarStack.back().Get(name);
+ std::vector<cmDefinitions*> defPtrs;
+ defPtrs.reserve(this->VarStack.size());
+ for (std::list<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*>::const_reverse_iterator it = defPtrs.rbegin();
+ for ( ; it != defPtrs.rend(); ++it)
+ {
+ result = (*it)->Get(name);
+ if(result.second)
+ {
+ break;
+ }
+ }
+ std::vector<cmDefinitions*>::const_reverse_iterator last = it;
+ // Store the result in intermediate scopes.
+ for (it = defPtrs.rbegin(); it != last; ++it)
+ {
+ (*it)->Set(name, result.first);
+ }
+ return result.first;
}
void SetDefinition(std::string const& name, std::string const& value)
-----------------------------------------------------------------------
Summary of changes:
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list