forked from mirrors/0ad
Avoid slightly-expensive QueryInterface() calls
Add CEntityHandle which wraps an entity_id_t and also has a pointer to a per-entity array of IComponents. QueryInterface/CmpPtr on a handle just involve a couple of pointer dereferences instead of a map lookup. This requires sizeof(void*) per registered interface type per entity, which is currently ~0.5KB per entity, which shouldn't be a problem. This was SVN commit r13825.
This commit is contained in:
@@ -260,6 +260,7 @@ bool CComponentManager::DeserializeState(std::istream& stream)
|
||||
CStdDeserializer deserializer(m_ScriptInterface, stream);
|
||||
|
||||
ResetState();
|
||||
InitSystemEntity();
|
||||
|
||||
std::string rng;
|
||||
deserializer.StringASCII("rng", rng, 0, 32);
|
||||
@@ -292,7 +293,7 @@ bool CComponentManager::DeserializeState(std::istream& stream)
|
||||
{
|
||||
entity_id_t ent;
|
||||
deserializer.NumberU32_Unbounded("entity id", ent);
|
||||
IComponent* component = ConstructComponent(ent, ctid);
|
||||
IComponent* component = ConstructComponent(LookupEntityHandle(ent, true), ctid);
|
||||
if (!component)
|
||||
return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user