diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-05-17 11:21:02 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-05-19 20:36:51 (GMT) |
commit | ea7b962be2f157f60f143725948e56b2f9f07042 (patch) | |
tree | b76cc40154964fa0853a6aa71ae814737b034da8 | |
parent | c8cb66880c233414b6656ea3d23776f9ba07a4e4 (diff) | |
download | CMake-ea7b962be2f157f60f143725948e56b2f9f07042.zip CMake-ea7b962be2f157f60f143725948e56b2f9f07042.tar.gz CMake-ea7b962be2f157f60f143725948e56b2f9f07042.tar.bz2 |
cmMakefile: Raise variable in scope explicitly when needed.
The Get method implicitly pulls a copy of all variables into a local scope. This
is not necessary.
-rw-r--r-- | Source/cmDefinitions.cxx | 16 | ||||
-rw-r--r-- | Source/cmDefinitions.h | 6 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 2 |
3 files changed, 17 insertions, 7 deletions
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index e2c6876..d7b6279 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -18,7 +18,7 @@ cmDefinitions::Def cmDefinitions::NoDef; //---------------------------------------------------------------------------- cmDefinitions::Def const& cmDefinitions::GetInternal( - const std::string& key, StackIter begin, StackIter end) + const std::string& key, StackIter begin, StackIter end, bool raise) { assert(begin != end); MapType::const_iterator i = begin->Map.find(key); @@ -32,7 +32,11 @@ cmDefinitions::Def const& cmDefinitions::GetInternal( { return cmDefinitions::NoDef; } - Def const& def = cmDefinitions::GetInternal(key, it, end); + Def const& def = cmDefinitions::GetInternal(key, it, end, raise); + if (!raise) + { + return def; + } return begin->Map.insert(MapType::value_type(key, def)).first->second; } @@ -40,10 +44,16 @@ cmDefinitions::Def const& cmDefinitions::GetInternal( const char* cmDefinitions::Get(const std::string& key, StackIter begin, StackIter end) { - Def const& def = cmDefinitions::GetInternal(key, begin, end); + Def const& def = cmDefinitions::GetInternal(key, begin, end, false); return def.Exists? def.c_str() : 0; } +void cmDefinitions::Raise(const std::string& key, + StackIter begin, StackIter end) +{ + cmDefinitions::GetInternal(key, begin, end, true); +} + //---------------------------------------------------------------------------- void cmDefinitions::Set(const std::string& key, const char* value) { diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index bf791ed..17b9c7c 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -35,11 +35,11 @@ class cmDefinitions typedef std::list<cmDefinitions>::reverse_iterator StackIter; typedef std::list<cmDefinitions>::const_reverse_iterator StackConstIter; public: - /** Get the value associated with a key; null if none. - Store the result locally if it came from a parent. */ static const char* Get(const std::string& key, StackIter begin, StackIter end); + static void Raise(const std::string& key, StackIter begin, StackIter end); + /** Set (or unset if null) a value associated with a key. */ void Set(const std::string& key, const char* value); @@ -80,7 +80,7 @@ private: MapType Map; static Def const& GetInternal(const std::string& key, - StackIter begin, StackIter end); + StackIter begin, StackIter end, bool raise); }; #endif diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 21c9f47..adba110 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -130,7 +130,7 @@ public: return true; } // First localize the definition in the current scope. - this->GetDefinition(var); + cmDefinitions::Raise(var, this->VarStack.rbegin(), this->VarStack.rend()); // Now update the definition in the parent scope. it->Set(var, varDef); |