From 984ebc3350f72cb005999f7b796803f83be15304 Mon Sep 17 00:00:00 2001 From: Patrick Gansterer Date: Mon, 19 Nov 2012 15:56:31 +0100 Subject: [PATCH] Search generator in cmake::ExtraGenerators before in cmake::Generators Since ExtraGenerators does not contain items, which are in Generators too, there is not change in behaviour. The benefit of this change is, that the lookup in the Generators map is now only done once. --- Source/cmake.cxx | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 2d531ba2b..cd7150730 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1889,29 +1889,32 @@ void cmake::GetRegisteredGenerators(std::vector& names) cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name) { - cmGlobalGenerator* generator = 0; cmExternalMakefileProjectGenerator* extraGenerator = 0; - RegisteredGeneratorsMap::const_iterator genIt = this->Generators.find(name); - if(genIt == this->Generators.end()) + RegisteredExtraGeneratorsMap::const_iterator extraGenIt = + this->ExtraGenerators.find(name); + if (extraGenIt != this->ExtraGenerators.end()) { - RegisteredExtraGeneratorsMap::const_iterator extraGenIt = - this->ExtraGenerators.find(name); - if (extraGenIt == this->ExtraGenerators.end()) - { - return 0; - } extraGenerator = (extraGenIt->second)(); - genIt=this->Generators.find(extraGenerator->GetGlobalGeneratorName(name)); - if(genIt == this->Generators.end()) - { - delete extraGenerator; - return 0; - } - } + name = extraGenerator->GetGlobalGeneratorName(name); + } + + cmGlobalGenerator* generator = 0; + RegisteredGeneratorsMap::const_iterator genIt = this->Generators.find(name); + if(genIt != this->Generators.end()) + { + generator = genIt->second->CreateGlobalGenerator(); + } + + if (generator) + { + generator->SetCMakeInstance(this); + generator->SetExternalMakefileProjectGenerator(extraGenerator); + } + else + { + delete extraGenerator; + } - generator = genIt->second->CreateGlobalGenerator(); - generator->SetCMakeInstance(this); - generator->SetExternalMakefileProjectGenerator(extraGenerator); return generator; }