1
0
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:
Ykkrosh
2013-09-11 20:41:53 +00:00
parent 87753bf3fd
commit 05422ad545
35 changed files with 530 additions and 264 deletions
@@ -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;