diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2014-12-01 17:56:46 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-12-02 15:51:15 (GMT) |
commit | 48f78f5f9ed3a7e0717359720ecc157418f55155 (patch) | |
tree | 9d11532cf1202699246b6007bd1a6723e4504a5b /Source/cmGlobalXCodeGenerator.cxx | |
parent | 3350e4d209b6a7ff758ca371af4d62844a66ab36 (diff) | |
download | CMake-48f78f5f9ed3a7e0717359720ecc157418f55155.zip CMake-48f78f5f9ed3a7e0717359720ecc157418f55155.tar.gz CMake-48f78f5f9ed3a7e0717359720ecc157418f55155.tar.bz2 |
Xcode: use a map to look up target pointers (#15201)
Use an efficient internal lookup to associate cmTarget and cmXCodeObject
instances.
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index b9f64e2..d222288 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -557,6 +557,7 @@ void cmGlobalXCodeGenerator::ClearXCodeObjects() } this->XCodeObjects.clear(); this->XCodeObjectIDs.clear(); + this->XCodeObjectMap.clear(); this->GroupMap.clear(); this->GroupNameMap.clear(); this->TargetGroup.clear(); @@ -2458,6 +2459,7 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) target->AddAttribute("name", this->CreateString(cmtarget.GetName())); target->AddAttribute("productName",this->CreateString(cmtarget.GetName())); target->SetTarget(&cmtarget); + this->XCodeObjectMap[&cmtarget] = target; // Add source files without build rules for editing convenience. if(cmtarget.GetType() == cmTarget::UTILITY) @@ -2661,6 +2663,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, target->AddAttribute("productType", this->CreateString(productType)); } target->SetTarget(&cmtarget); + this->XCodeObjectMap[&cmtarget] = target; target->SetId(this->GetOrCreateId( cmtarget.GetName(), target->GetId()).c_str()); return target; @@ -2673,16 +2676,14 @@ cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget const* t) { return 0; } - for(std::vector<cmXCodeObject*>::iterator i = this->XCodeObjects.begin(); - i != this->XCodeObjects.end(); ++i) + + std::map<cmTarget const*, cmXCodeObject*>::const_iterator const i = + this->XCodeObjectMap.find(t); + if (i == this->XCodeObjectMap.end()) { - cmXCodeObject* o = *i; - if(o->GetTarget() == t) - { - return o; - } + return 0; } - return 0; + return i->second; } //---------------------------------------------------------------------------- |