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:
parent
3350e4d209
commit
48f78f5f9e
|
@ -557,6 +557,7 @@ void cmGlobalXCodeGenerator::ClearXCodeObjects()
|
||||||
}
|
}
|
||||||
this->XCodeObjects.clear();
|
this->XCodeObjects.clear();
|
||||||
this->XCodeObjectIDs.clear();
|
this->XCodeObjectIDs.clear();
|
||||||
|
this->XCodeObjectMap.clear();
|
||||||
this->GroupMap.clear();
|
this->GroupMap.clear();
|
||||||
this->GroupNameMap.clear();
|
this->GroupNameMap.clear();
|
||||||
this->TargetGroup.clear();
|
this->TargetGroup.clear();
|
||||||
|
@ -2458,6 +2459,7 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget)
|
||||||
target->AddAttribute("name", this->CreateString(cmtarget.GetName()));
|
target->AddAttribute("name", this->CreateString(cmtarget.GetName()));
|
||||||
target->AddAttribute("productName",this->CreateString(cmtarget.GetName()));
|
target->AddAttribute("productName",this->CreateString(cmtarget.GetName()));
|
||||||
target->SetTarget(&cmtarget);
|
target->SetTarget(&cmtarget);
|
||||||
|
this->XCodeObjectMap[&cmtarget] = target;
|
||||||
|
|
||||||
// Add source files without build rules for editing convenience.
|
// Add source files without build rules for editing convenience.
|
||||||
if(cmtarget.GetType() == cmTarget::UTILITY)
|
if(cmtarget.GetType() == cmTarget::UTILITY)
|
||||||
|
@ -2661,6 +2663,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget,
|
||||||
target->AddAttribute("productType", this->CreateString(productType));
|
target->AddAttribute("productType", this->CreateString(productType));
|
||||||
}
|
}
|
||||||
target->SetTarget(&cmtarget);
|
target->SetTarget(&cmtarget);
|
||||||
|
this->XCodeObjectMap[&cmtarget] = target;
|
||||||
target->SetId(this->GetOrCreateId(
|
target->SetId(this->GetOrCreateId(
|
||||||
cmtarget.GetName(), target->GetId()).c_str());
|
cmtarget.GetName(), target->GetId()).c_str());
|
||||||
return target;
|
return target;
|
||||||
|
@ -2673,17 +2676,15 @@ cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget const* t)
|
||||||
{
|
{
|
||||||
return 0;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
std::string cmGlobalXCodeGenerator::GetOrCreateId(const std::string& name,
|
std::string cmGlobalXCodeGenerator::GetOrCreateId(const std::string& name,
|
||||||
|
|
|
@ -241,6 +241,7 @@ private:
|
||||||
std::map<std::string, cmXCodeObject* > GroupNameMap;
|
std::map<std::string, cmXCodeObject* > GroupNameMap;
|
||||||
std::map<std::string, cmXCodeObject* > TargetGroup;
|
std::map<std::string, cmXCodeObject* > TargetGroup;
|
||||||
std::map<std::string, cmXCodeObject* > FileRefs;
|
std::map<std::string, cmXCodeObject* > FileRefs;
|
||||||
|
std::map<cmTarget const*, cmXCodeObject* > XCodeObjectMap;
|
||||||
std::vector<std::string> Architectures;
|
std::vector<std::string> Architectures;
|
||||||
std::string GeneratorToolset;
|
std::string GeneratorToolset;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue