From 60becdc65c5f8cfad4b2c6a33e3649d2acbddf39 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 26 Apr 2015 16:00:18 +0200 Subject: cmDefinitions: Implement MakeClosure in terms of a list of ancestors. --- Source/cmDefinitions.cxx | 25 +++++++++++++------------ Source/cmDefinitions.h | 5 ++++- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 5fe57c8..873a7b4 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -11,8 +11,6 @@ ============================================================================*/ #include "cmDefinitions.h" -#include - //---------------------------------------------------------------------------- cmDefinitions::Def cmDefinitions::NoDef; @@ -81,22 +79,25 @@ cmDefinitions cmDefinitions::MakeClosure() const { std::set undefined; cmDefinitions closure; - closure.MakeClosure(undefined, this); - return closure; -} - -//---------------------------------------------------------------------------- -void cmDefinitions::MakeClosure(std::set& undefined, - cmDefinitions const* defs) -{ + cmDefinitions const* defs = this; std::list ups; while(defs) { ups.push_back(defs); defs = defs->Up; } - for (std::list::const_iterator it = ups.begin(); - it != ups.end(); ++it) + closure.MakeClosure(undefined, ups.begin(), ups.end()); + return closure; +} + +//---------------------------------------------------------------------------- +void +cmDefinitions::MakeClosure(std::set& undefined, + std::list::iterator begin, + std::list::iterator end) +{ + for (std::list::const_iterator it = begin; + it != end; ++it) { // Consider local definitions. for(MapType::const_iterator mi = (*it)->Map.begin(); diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 6917402..40e0531 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -17,6 +17,8 @@ #include "cmsys/hash_map.hxx" #endif +#include + /** \class cmDefinitions * \brief Store a scope of variable definitions for CMake language. * @@ -80,7 +82,8 @@ private: Def const& GetInternal(const std::string& key); void MakeClosure(std::set& undefined, - cmDefinitions const* defs); + std::list::iterator begin, + std::list::iterator end); }; #endif -- cgit v0.12