cmDefinitions: Externalize looping for ClosureKeys.
This commit is contained in:
parent
f79cd99d6d
commit
5ccff6408c
|
@ -116,26 +116,19 @@ cmDefinitions::MakeClosure(std::set<std::string>& undefined,
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::vector<std::string> cmDefinitions::ClosureKeys() const
|
||||
std::vector<std::string>
|
||||
cmDefinitions::ClosureKeys(std::set<std::string>& bound) const
|
||||
{
|
||||
std::vector<std::string> defined;
|
||||
std::set<std::string> bound;
|
||||
|
||||
cmDefinitions const* up = this;
|
||||
|
||||
while (up)
|
||||
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(bound.insert(mi->first).second && mi->second.Exists)
|
||||
{
|
||||
// Use this key if it is not already set or unset.
|
||||
if(bound.insert(mi->first).second && mi->second.Exists)
|
||||
{
|
||||
defined.push_back(mi->first);
|
||||
}
|
||||
defined.push_back(mi->first);
|
||||
}
|
||||
up = up->Up;
|
||||
}
|
||||
return defined;
|
||||
}
|
||||
|
|
|
@ -47,8 +47,8 @@ public:
|
|||
/** Get the set of all local keys. */
|
||||
std::vector<std::string> LocalKeys() const;
|
||||
|
||||
/** Compute the set of all defined keys. */
|
||||
std::vector<std::string> ClosureKeys() const;
|
||||
std::vector<std::string>
|
||||
ClosureKeys(std::set<std::string>& bound) const;
|
||||
|
||||
static cmDefinitions MakeClosure(
|
||||
std::list<cmDefinitions>::const_reverse_iterator rbegin,
|
||||
|
|
|
@ -98,7 +98,16 @@ public:
|
|||
|
||||
std::vector<std::string> ClosureKeys() const
|
||||
{
|
||||
return this->VarStack.back().ClosureKeys();
|
||||
std::vector<std::string> closureKeys;
|
||||
std::set<std::string> bound;
|
||||
for (std::list<cmDefinitions>::const_reverse_iterator it =
|
||||
this->VarStack.rbegin(); it != this->VarStack.rend(); ++it)
|
||||
{
|
||||
std::vector<std::string> const& localKeys = it->ClosureKeys(bound);
|
||||
closureKeys.insert(closureKeys.end(),
|
||||
localKeys.begin(), localKeys.end());
|
||||
}
|
||||
return closureKeys;
|
||||
}
|
||||
|
||||
void PopDefinitions()
|
||||
|
|
Loading…
Reference in New Issue