From f79cd99d6dcdfcdcd341c5ea90a5f2d9c4d6d3bc Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 29 Apr 2015 23:48:43 +0200 Subject: cmDefinitions: Implement MakeClosure in terms of reverse iterators. Iterate directly over the parent content provided by cmMakefile. --- Source/cmDefinitions.cxx | 18 +++++++++--------- Source/cmDefinitions.h | 8 ++++---- Source/cmMakefile.cxx | 12 +++--------- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index d1fbe74..718d9ec 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -76,27 +76,27 @@ std::vector cmDefinitions::LocalKeys() const //---------------------------------------------------------------------------- cmDefinitions cmDefinitions::MakeClosure( - std::list::iterator begin, - std::list::iterator end) + std::list::const_reverse_iterator rbegin, + std::list::const_reverse_iterator rend) { std::set undefined; cmDefinitions closure; - closure.MakeClosure(undefined, begin, end); + closure.MakeClosure(undefined, rbegin, rend); return closure; } //---------------------------------------------------------------------------- void cmDefinitions::MakeClosure(std::set& undefined, - std::list::iterator begin, - std::list::iterator end) + std::list::const_reverse_iterator rbegin, + std::list::const_reverse_iterator rend) { - for (std::list::const_iterator it = begin; - it != end; ++it) + for (std::list::const_reverse_iterator it = rbegin; + it != rend; ++it) { // Consider local definitions. - for(MapType::const_iterator mi = (*it)->Map.begin(); - mi != (*it)->Map.end(); ++mi) + for(MapType::const_iterator mi = it->Map.begin(); + mi != it->Map.end(); ++mi) { // Use this key if it is not already set or unset. if(this->Map.find(mi->first) == this->Map.end() && diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 67b6170..87f5c34 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -51,8 +51,8 @@ public: std::vector ClosureKeys() const; static cmDefinitions MakeClosure( - std::list::iterator begin, - std::list::iterator end); + std::list::const_reverse_iterator rbegin, + std::list::const_reverse_iterator rend); private: // String with existence boolean. @@ -84,8 +84,8 @@ private: Def const& GetInternal(const std::string& key); void MakeClosure(std::set& undefined, - std::list::iterator begin, - std::list::iterator end); + std::list::const_reverse_iterator rbegin, + std::list::const_reverse_iterator rend); }; #endif diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8797090..6451874 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -63,15 +63,9 @@ public: void InitializeDefinitions(cmMakefile* parent) { - std::list defPtrs; - for (std::list::iterator it = - parent->Internal->VarStack.begin(); - it != parent->Internal->VarStack.end(); ++it) - { - defPtrs.push_back(&*it); - } - this->VarStack.back() = cmDefinitions::MakeClosure(defPtrs.begin(), - defPtrs.end()); + this->VarStack.back() = + cmDefinitions::MakeClosure(parent->Internal->VarStack.rbegin(), + parent->Internal->VarStack.rend()); } const char* GetDefinition(std::string const& name) -- cgit v0.12