From 4443adc1c0450a49a4413669a8ade5487f9f3026 Mon Sep 17 00:00:00 2001 From: Frank Winklmeier Date: Tue, 30 Jan 2018 17:51:14 +0100 Subject: cmLocalGenerator: remove public GetImportedGeneratorTargets GetImportedGeneratorTargets is not used anywhere hence remove it to avoid exposing the type of ImportedGeneratorTargets. --- Source/cmLocalGenerator.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index a66fa6e..2131085 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -139,11 +139,6 @@ public: return this->GeneratorTargets; } - const std::vector& GetImportedGeneratorTargets() const - { - return this->ImportedGeneratorTargets; - } - void AddGeneratorTarget(cmGeneratorTarget* gt); void AddImportedGeneratorTarget(cmGeneratorTarget* gt); void AddOwnedImportedGeneratorTarget(cmGeneratorTarget* gt); -- cgit v0.12 From aed227fd5ae6775a5bbdd54540666a70163c9fcb Mon Sep 17 00:00:00 2001 From: Frank Winklmeier Date: Mon, 29 Jan 2018 16:11:07 +0100 Subject: cmLocalGenerator: change ImportedGeneratorTargets from vector to map For large number of targets significant amount of time is spent in cmLocalGenerator::FindGeneratorTargetToUse, which uses find_if on a vector to locate the given target. Using a map instead of vector for ImportedGeneratorTargets (as done for cmMakefile::ImportedTargets) provides a significant speedup (up to factor of 2). --- Source/cmLocalGenerator.cxx | 28 +++++----------------------- Source/cmLocalGenerator.h | 2 +- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 859aa44..afdcc84 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -553,14 +553,13 @@ void cmLocalGenerator::GenerateInstallRules() void cmLocalGenerator::AddGeneratorTarget(cmGeneratorTarget* gt) { this->GeneratorTargets.push_back(gt); - this->GeneratorTargetSearchIndex.insert( - std::pair(gt->GetName(), gt)); + this->GeneratorTargetSearchIndex.emplace(gt->GetName(), gt); this->GlobalGenerator->IndexGeneratorTarget(gt); } void cmLocalGenerator::AddImportedGeneratorTarget(cmGeneratorTarget* gt) { - this->ImportedGeneratorTargets.push_back(gt); + this->ImportedGeneratorTargets.emplace(gt->GetName(), gt); this->GlobalGenerator->IndexGeneratorTarget(gt); } @@ -569,22 +568,6 @@ void cmLocalGenerator::AddOwnedImportedGeneratorTarget(cmGeneratorTarget* gt) this->OwnedImportedGeneratorTargets.push_back(gt); } -struct NamedGeneratorTargetFinder -{ - NamedGeneratorTargetFinder(std::string const& name) - : Name(name) - { - } - - bool operator()(cmGeneratorTarget* tgt) - { - return tgt->GetName() == this->Name; - } - -private: - std::string Name; -}; - cmGeneratorTarget* cmLocalGenerator::FindLocalNonAliasGeneratorTarget( const std::string& name) const { @@ -1395,11 +1378,10 @@ void cmLocalGenerator::AddLanguageFlagsForLinking( cmGeneratorTarget* cmLocalGenerator::FindGeneratorTargetToUse( const std::string& name) const { - std::vector::const_iterator imported = std::find_if( - this->ImportedGeneratorTargets.begin(), - this->ImportedGeneratorTargets.end(), NamedGeneratorTargetFinder(name)); + GeneratorTargetMap::const_iterator imported = + this->ImportedGeneratorTargets.find(name); if (imported != this->ImportedGeneratorTargets.end()) { - return *imported; + return imported->second; } if (cmGeneratorTarget* t = this->FindLocalNonAliasGeneratorTarget(name)) { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 2131085..58bbe77 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -389,7 +389,7 @@ protected: std::vector GeneratorTargets; std::set WarnCMP0063; - std::vector ImportedGeneratorTargets; + GeneratorTargetMap ImportedGeneratorTargets; std::vector OwnedImportedGeneratorTargets; std::map AliasTargets; -- cgit v0.12