Xcode: use a map to look up target pointers (#15201)

Use an efficient internal lookup to associate cmTarget and cmXCodeObject
instances.
This commit is contained in:
Ben Boeckel 2014-12-01 12:56:46 -05:00 committed by Brad King
parent 3350e4d209
commit 48f78f5f9e
2 changed files with 10 additions and 8 deletions

View File

@ -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;
}
//----------------------------------------------------------------------------

View File

@ -241,6 +241,7 @@ private:
std::map<std::string, cmXCodeObject* > GroupNameMap;
std::map<std::string, cmXCodeObject* > TargetGroup;
std::map<std::string, cmXCodeObject* > FileRefs;
std::map<cmTarget const*, cmXCodeObject* > XCodeObjectMap;
std::vector<std::string> Architectures;
std::string GeneratorToolset;
};