cmDefinitions: Change LocalKeys to return a vector.

This is more efficient and we lose nothing.
This commit is contained in:
Stephen Kelly 2015-04-26 16:34:13 +02:00
parent 5067ae41b0
commit 818bf727c1
3 changed files with 10 additions and 9 deletions

View File

@ -58,16 +58,17 @@ void cmDefinitions::Erase(const std::string& key)
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::set<std::string> cmDefinitions::LocalKeys() const std::vector<std::string> cmDefinitions::LocalKeys() const
{ {
std::set<std::string> keys; std::vector<std::string> keys;
keys.reserve(this->Map.size());
// Consider local definitions. // Consider local definitions.
for(MapType::const_iterator mi = this->Map.begin(); for(MapType::const_iterator mi = this->Map.begin();
mi != this->Map.end(); ++mi) mi != this->Map.end(); ++mi)
{ {
if (mi->second.Exists) if (mi->second.Exists)
{ {
keys.insert(mi->first); keys.push_back(mi->first);
} }
} }
return keys; return keys;

View File

@ -43,7 +43,7 @@ public:
void Erase(const std::string& key); void Erase(const std::string& key);
/** Get the set of all local keys. */ /** Get the set of all local keys. */
std::set<std::string> LocalKeys() const; std::vector<std::string> LocalKeys() const;
/** Compute the closure of all defined keys with values. /** Compute the closure of all defined keys with values.
This flattens the scope. The result has no parent. */ This flattens the scope. The result has no parent. */

View File

@ -89,7 +89,7 @@ public:
} }
} }
std::set<std::string> LocalKeys() const std::vector<std::string> LocalKeys() const
{ {
return this->VarStack.top().LocalKeys(); return this->VarStack.top().LocalKeys();
} }
@ -1901,8 +1901,8 @@ void cmMakefile::CheckForUnusedVariables() const
{ {
return; return;
} }
const std::set<std::string>& locals = this->Internal->LocalKeys(); const std::vector<std::string>& locals = this->Internal->LocalKeys();
std::set<std::string>::const_iterator it = locals.begin(); std::vector<std::string>::const_iterator it = locals.begin();
for (; it != locals.end(); ++it) for (; it != locals.end(); ++it)
{ {
this->CheckForUnused("out of scope", *it); this->CheckForUnused("out of scope", *it);
@ -4431,10 +4431,10 @@ void cmMakefile::PopScope()
std::set<std::string> init = this->Internal->VarInitStack.top(); std::set<std::string> init = this->Internal->VarInitStack.top();
std::set<std::string> usage = this->Internal->VarUsageStack.top(); std::set<std::string> usage = this->Internal->VarUsageStack.top();
const std::set<std::string>& locals = this->Internal->LocalKeys(); const std::vector<std::string>& locals = this->Internal->LocalKeys();
// Remove initialization and usage information for variables in the local // Remove initialization and usage information for variables in the local
// scope. // scope.
std::set<std::string>::const_iterator it = locals.begin(); std::vector<std::string>::const_iterator it = locals.begin();
for (; it != locals.end(); ++it) for (; it != locals.end(); ++it)
{ {
init.erase(*it); init.erase(*it);