diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-05-17 11:37:41 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-05-19 20:36:53 (GMT) |
commit | 2b09d9f346bd3220b059771a6da1bafb06ce0f5b (patch) | |
tree | aa6531a7fec1d25ca329a8dc8a01bd169c231734 /Source/cmDefinitions.cxx | |
parent | 528d68021c6769b2aa86ea9751a7308a84101ca2 (diff) | |
download | CMake-2b09d9f346bd3220b059771a6da1bafb06ce0f5b.zip CMake-2b09d9f346bd3220b059771a6da1bafb06ce0f5b.tar.gz CMake-2b09d9f346bd3220b059771a6da1bafb06ce0f5b.tar.bz2 |
cmMakefile: Remove VarInitStack.
In cmMakefile::PushScope, a copy of the closure of keys initialized
in the parent scope is made. In PopScope, essentially the same copy
is inserted back into the parent. That means a lot of duplication
of strings and a lot of string comparisons. None of it is needed,
because the cmDefinitions keys already provide a canonical
representation of what is initialized.
The removal of the separate container also makes the variable handling
code more easy to reason about in general.
Before this patch, configuring llvm uses 200 KiB for the VarInitStack.
Overall peak memory consumption goes from 35.5 MiB to 35.1 MiB.
Diffstat (limited to 'Source/cmDefinitions.cxx')
-rw-r--r-- | Source/cmDefinitions.cxx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 97a16ea..5b03bd4 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -54,6 +54,20 @@ void cmDefinitions::Raise(const std::string& key, cmDefinitions::GetInternal(key, begin, end, true); } +bool cmDefinitions::HasKey(const std::string& key, + StackConstIter begin, StackConstIter end) +{ + for (StackConstIter it = begin; it != end; ++it) + { + MapType::const_iterator i = it->Map.find(key); + if (i != it->Map.end()) + { + return true; + } + } + return false; +} + //---------------------------------------------------------------------------- void cmDefinitions::Set(const std::string& key, const char* value) { |