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
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Symmetric like `World.add` but idempotent
|
|
||||||
local function world_set(world: World, entity: i53, id: i53, data: unknown): ()
|
local function world_set(world: World, entity: i53, id: i53, data: unknown): ()
|
||||||
local entityIndex = world.entityIndex
|
local entityIndex = world.entityIndex
|
||||||
local record = entityIndex.sparse[entity]
|
local record = entityIndex.sparse[entity]
|
||||||
|
@ -1032,27 +1031,26 @@ do
|
||||||
if not ECS_IS_PAIR(id) then
|
if not ECS_IS_PAIR(id) then
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
|
local object = ECS_ENTITY_T_LO(id)
|
||||||
local id_record = component_index[id]
|
if object == delete then
|
||||||
|
local id_record = component_index[id]
|
||||||
if id_record then
|
|
||||||
local flags = id_record.flags
|
local flags = id_record.flags
|
||||||
if bit32.band(flags, ECS_ID_DELETE) ~= 0 then
|
if bit32.band(flags, ECS_ID_DELETE) ~= 0 then
|
||||||
for _, child in children do
|
for _, child in children do
|
||||||
-- Cascade deletions of it has Delete as component trait
|
-- Cascade deletions of it has Delete as component trait
|
||||||
world_delete(world, child, destruct)
|
world_delete(world, child, destruct)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
break
|
||||||
else
|
else
|
||||||
local object = ECS_ENTITY_T_LO(id)
|
for _, child in children do
|
||||||
if object == delete then
|
world_remove(world, child, id)
|
||||||
for _, child in children do
|
end
|
||||||
world_remove(world, child, id)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
archetype_destroy(world, idr_t_archetype)
|
archetype_destroy(world, idr_t_archetype)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue