diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-04-26 13:38:36 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-04-29 22:32:18 (GMT) |
commit | 5ccff6408c93e67d7f8445ce1bf6465b068d6f6b (patch) | |
tree | 4f1b66350da2c061872dd17713e26c856eb45a7c | |
parent | f79cd99d6dcdfcdcd341c5ea90a5f2d9c4d6d3bc (diff) | |
download | CMake-5ccff6408c93e67d7f8445ce1bf6465b068d6f6b.zip CMake-5ccff6408c93e67d7f8445ce1bf6465b068d6f6b.tar.gz CMake-5ccff6408c93e67d7f8445ce1bf6465b068d6f6b.tar.bz2 |
cmDefinitions: Externalize looping for ClosureKeys.
-rw-r--r-- | Source/cmDefinitions.cxx | 23 | ||||
-rw-r--r-- | Source/cmDefinitions.h | 4 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 11 |
3 files changed, 20 insertions, 18 deletions
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 718d9ec..115e30a 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -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; } diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 87f5c34..4c7f11f 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -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, diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 6451874..1d3e496 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -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() |