mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 17:10:03 +00:00
Improve world_delete performance
This commit is contained in:
parent
8320d1ce49
commit
31880b71ac
1 changed files with 13 additions and 15 deletions
|
@ -727,7 +727,6 @@ local function world_add(world: World, entity: i53, id: i53): ()
|
|||
end
|
||||
end
|
||||
|
||||
-- Symmetric like `World.add` but idempotent
|
||||
local function world_set(world: World, entity: i53, id: i53, data: unknown): ()
|
||||
local entityIndex = world.entityIndex
|
||||
local record = entityIndex.sparse[entity]
|
||||
|
@ -1032,27 +1031,26 @@ do
|
|||
if not ECS_IS_PAIR(id) then
|
||||
continue
|
||||
end
|
||||
|
||||
local id_record = component_index[id]
|
||||
|
||||
if id_record then
|
||||
local object = ECS_ENTITY_T_LO(id)
|
||||
if object == delete then
|
||||
local id_record = component_index[id]
|
||||
local flags = id_record.flags
|
||||
if bit32.band(flags, ECS_ID_DELETE) ~= 0 then
|
||||
for _, child in children do
|
||||
-- Cascade deletions of it has Delete as component trait
|
||||
world_delete(world, child, destruct)
|
||||
end
|
||||
for _, child in children do
|
||||
-- Cascade deletions of it has Delete as component trait
|
||||
world_delete(world, child, destruct)
|
||||
end
|
||||
|
||||
break
|
||||
else
|
||||
local object = ECS_ENTITY_T_LO(id)
|
||||
if object == delete then
|
||||
for _, child in children do
|
||||
world_remove(world, child, id)
|
||||
end
|
||||
end
|
||||
for _, child in children do
|
||||
world_remove(world, child, id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
archetype_destroy(world, idr_t_archetype)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue