shorten loop

This commit is contained in:
lolmanurfunny 2025-03-07 23:17:43 -05:00
parent fa4df24ada
commit 870823f9fc

View file

@ -1176,24 +1176,14 @@ do
local on_remove = id_record.hooks.on_remove local on_remove = id_record.hooks.on_remove
local to = archetype_traverse_remove(world, id, idr_t_archetype) local to = archetype_traverse_remove(world, id, idr_t_archetype)
local empty = #to.types == 0 local empty = #to.types == 0
for i = n, 1, -1 do
if on_remove then local child = children[i]
for i = n, 1, -1 do if on_remove then
local child = children[i]
on_remove(child) on_remove(child)
if not empty then
local r = sparse_array[ECS_ENTITY_T_LO(child)]
entity_move(entity_index, child, r, to)
end
end end
else if not empty then
if not empty then -- no on_remove hook set; fast path local r = sparse_array[ECS_ENTITY_T_LO(child)]
for i = n, 1, -1 do entity_move(entity_index, child, r, to)
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 end