From a0de6a7ed7cbb1b328cd55d1d62ee78cbda9a8b7 Mon Sep 17 00:00:00 2001 From: Ramine Agoune Date: Mon, 17 Mar 2025 16:35:25 +0100 Subject: [PATCH] feat: use on archetype components in RemoveEntity Use the archetype's components instead of the whole storages in RemoveEntity. This method got really slower after the Tag feature, because the slice of storages is now bigger (2048 instead of 256). --- world.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/world.go b/world.go index 60cf0c4..ace9694 100644 --- a/world.go +++ b/world.go @@ -248,7 +248,8 @@ func (world *World) RemoveEntity(entityId EntityId) { archetype := world.archetypes[entityRecord.archetypeId] lastEntityKey := len(archetype.entities) - 1 - for _, s := range world.storage { + for _, componentId := range archetype.Type { + s := world.storage[componentId] if s != nil && slices.Contains(archetype.Type, s.getType()) { s.moveLastToKey(archetype.Id, entityRecord.key) }