From f170985e7aaec7562ca481bab49228ece233c4e4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 16 May 2015 05:33:30 +0200 Subject: [PATCH] cmDefinitions: Make the ClosureKeys method static. For consistency with all other closure-related methods. --- Source/cmDefinitions.cxx | 20 +++++++++++++------- Source/cmDefinitions.h | 4 ++-- Source/cmMakefile.cxx | 12 ++---------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 6fcc002b6..e2c687632 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -105,18 +105,24 @@ cmDefinitions cmDefinitions::MakeClosure(StackConstIter begin, //---------------------------------------------------------------------------- std::vector -cmDefinitions::ClosureKeys(std::set& bound) const +cmDefinitions::ClosureKeys(StackConstIter begin, StackConstIter end) { + std::set bound; std::vector defined; - defined.reserve(this->Map.size()); - for(MapType::const_iterator mi = this->Map.begin(); - mi != this->Map.end(); ++mi) + + for (StackConstIter it = begin; it != end; ++it) { - // Use this key if it is not already set or unset. - if(bound.insert(mi->first).second && mi->second.Exists) + defined.reserve(defined.size() + it->Map.size()); + 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; } diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index b95ae6ba5..80643a96d 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -44,8 +44,8 @@ public: /** Get the set of all local keys. */ std::vector LocalKeys() const; - std::vector - ClosureKeys(std::set& bound) const; + static std::vector ClosureKeys(StackConstIter begin, + StackConstIter end); static cmDefinitions MakeClosure(StackConstIter begin, StackConstIter end); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7b8d3afa5..9f9171c08 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -94,16 +94,8 @@ public: std::vector ClosureKeys() const { - std::vector closureKeys; - std::set bound; - for (std::list::const_reverse_iterator it = - this->VarStack.rbegin(); it != this->VarStack.rend(); ++it) - { - std::vector const& localKeys = it->ClosureKeys(bound); - closureKeys.insert(closureKeys.end(), - localKeys.begin(), localKeys.end()); - } - return closureKeys; + return cmDefinitions::ClosureKeys(this->VarStack.rbegin(), + this->VarStack.rend()); } void PopDefinitions()