cmDefinitions: Make the ClosureKeys method static.

For consistency with all other closure-related methods.
This commit is contained in:
Stephen Kelly 2015-05-16 05:33:30 +02:00
parent 98c5c90361
commit f170985e7a
3 changed files with 17 additions and 19 deletions

View File

@ -105,18 +105,24 @@ cmDefinitions cmDefinitions::MakeClosure(StackConstIter begin,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::vector<std::string> std::vector<std::string>
cmDefinitions::ClosureKeys(std::set<std::string>& bound) const cmDefinitions::ClosureKeys(StackConstIter begin, StackConstIter end)
{ {
std::set<std::string> bound;
std::vector<std::string> defined; std::vector<std::string> defined;
defined.reserve(this->Map.size());
for(MapType::const_iterator mi = this->Map.begin(); for (StackConstIter it = begin; it != end; ++it)
mi != this->Map.end(); ++mi)
{ {
// Use this key if it is not already set or unset. defined.reserve(defined.size() + it->Map.size());
if(bound.insert(mi->first).second && mi->second.Exists) for(MapType::const_iterator mi = it->Map.begin();
mi != it->Map.end(); ++mi)
{ {
defined.push_back(mi->first); // 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);
}
} }
} }
return defined; return defined;
} }

View File

@ -44,8 +44,8 @@ public:
/** Get the set of all local keys. */ /** Get the set of all local keys. */
std::vector<std::string> LocalKeys() const; std::vector<std::string> LocalKeys() const;
std::vector<std::string> static std::vector<std::string> ClosureKeys(StackConstIter begin,
ClosureKeys(std::set<std::string>& bound) const; StackConstIter end);
static cmDefinitions MakeClosure(StackConstIter begin, StackConstIter end); static cmDefinitions MakeClosure(StackConstIter begin, StackConstIter end);

View File

@ -94,16 +94,8 @@ public:
std::vector<std::string> ClosureKeys() const std::vector<std::string> ClosureKeys() const
{ {
std::vector<std::string> closureKeys; return cmDefinitions::ClosureKeys(this->VarStack.rbegin(),
std::set<std::string> bound; this->VarStack.rend());
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() void PopDefinitions()