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.
This commit is contained in:
parent
c8cb66880c
commit
ea7b962be2
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue