Skip to content

Commit e0fcfda

Browse files
authored
feat: use on archetype components in RemoveEntity (#21)
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).
1 parent 28eb5ac commit e0fcfda

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

world.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ func (world *World) RemoveEntity(entityId EntityId) {
248248
archetype := world.archetypes[entityRecord.archetypeId]
249249

250250
lastEntityKey := len(archetype.entities) - 1
251-
for _, s := range world.storage {
251+
for _, componentId := range archetype.Type {
252+
s := world.storage[componentId]
252253
if s != nil && slices.Contains(archetype.Type, s.getType()) {
253254
s.moveLastToKey(archetype.Id, entityRecord.key)
254255
}

0 commit comments

Comments
 (0)