mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 17:10:03 +00:00
shorten loop
This commit is contained in:
parent
fa4df24ada
commit
870823f9fc
1 changed files with 6 additions and 16 deletions
14
jecs.luau
14
jecs.luau
|
@ -1176,26 +1176,16 @@ do
|
|||
local on_remove = id_record.hooks.on_remove
|
||||
local to = archetype_traverse_remove(world, id, idr_t_archetype)
|
||||
local empty = #to.types == 0
|
||||
|
||||
if on_remove then
|
||||
for i = n, 1, -1 do
|
||||
local child = children[i]
|
||||
if on_remove then
|
||||
on_remove(child)
|
||||
|
||||
end
|
||||
if not empty then
|
||||
local r = sparse_array[ECS_ENTITY_T_LO(child)]
|
||||
entity_move(entity_index, child, r, to)
|
||||
end
|
||||
end
|
||||
else
|
||||
if not empty then -- no on_remove hook set; fast path
|
||||
for i = n, 1, -1 do
|
||||
local child = children[i]
|
||||
local r = sparse_array[ECS_ENTITY_T_LO(child)]
|
||||
entity_move(entity_index, child, r, to)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue