Skip to content

Commit

Permalink
17568: Improves performance of destroy_entities by destroying the ent…
Browse files Browse the repository at this point in the history
…ity caches directly instead of removing data first (#9)
  • Loading branch information
howsohazard authored Sep 19, 2023
1 parent 51b7724 commit ed06c66
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Amalgam/entity/EntityQueryManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,21 @@ class EntityQueryManager
// then this function will move the entity data that was previously in index 5 to be referenced by index 3 for all caches
inline static void RemoveEntity(Entity *container, Entity *entity, size_t entity_index, size_t entity_index_to_reassign)
{
if(entity == nullptr || container == nullptr)
if(entity == nullptr)
return;

#ifdef MULTITHREAD_SUPPORT
Concurrency::WriteLock write_lock(queryCacheMutex);
#endif

auto found_cache = queryCaches.find(container);
if(found_cache != end(queryCaches))
if(container != nullptr)
{
found_cache->second->RemoveEntity(entity, entity_index, entity_index_to_reassign);
queryCaches.erase(entity);
}
auto found_cache = queryCaches.find(container);
if(found_cache != end(queryCaches))
found_cache->second->RemoveEntity(entity, entity_index, entity_index_to_reassign);
}

queryCaches.erase(entity);
}

//sorts the entities by their string ids
Expand Down

0 comments on commit ed06c66

Please sign in to comment.