From 012a75a00f060d6ca36cc9ffb97439a7ad526395 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 26 Apr 2015 15:36:49 +0200 Subject: [PATCH] cmDefinitions: Make ClosureKeys API vector-based. Construct the final list directly in a named return value. Use a single set to track bindings already found. Co-Author: Brad King --- Source/cmDefinitions.cxx | 12 +++++------- Source/cmDefinitions.h | 2 +- Source/cmMakefile.cxx | 5 ++--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 4b0eed459..f2100eb6a 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -119,10 +119,10 @@ void cmDefinitions::ClosureImpl(std::set& undefined, } //---------------------------------------------------------------------------- -std::set cmDefinitions::ClosureKeys() const +std::vector cmDefinitions::ClosureKeys() const { - std::set defined; - std::set undefined; + std::vector defined; + std::set bound; cmDefinitions const* up = this; @@ -133,11 +133,9 @@ std::set cmDefinitions::ClosureKeys() const mi != up->Map.end(); ++mi) { // Use this key if it is not already set or unset. - if(defined.find(mi->first) == defined.end() && - undefined.find(mi->first) == undefined.end()) + if(bound.insert(mi->first).second && mi->second.Exists) { - std::set& m = mi->second.Exists? defined : undefined; - m.insert(mi->first); + defined.push_back(mi->first); } } up = up->Up; diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 950970bb4..4664090bf 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -50,7 +50,7 @@ public: cmDefinitions Closure() const; /** Compute the set of all defined keys. */ - std::set ClosureKeys() const; + std::vector ClosureKeys() const; private: // String with existence boolean. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 9209e498d..e2a9f61f5 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -94,7 +94,7 @@ public: return this->VarStack.top().LocalKeys(); } - std::set ClosureKeys() const + std::vector ClosureKeys() const { return this->VarStack.top().ClosureKeys(); } @@ -2514,8 +2514,7 @@ std::vector cmMakefile std::vector res; if ( !cacheonly ) { - std::set definitions = this->Internal->ClosureKeys(); - res.insert(res.end(), definitions.begin(), definitions.end()); + res = this->Internal->ClosureKeys(); } std::vector cacheKeys = this->GetState()->GetCacheEntryKeys();