Index is not a stable pointer
Some checks are pending
analysis / Run Luau Analyze (push) Waiting to run
unit-testing / Run Luau Tests (push) Waiting to run

This commit is contained in:
Ukendio 2025-04-25 23:53:09 +02:00
parent b1a2bc48a7
commit d3b032666b

View file

@ -215,11 +215,11 @@ local function observers_add(world: jecs.World & { [string]: any }): PatchedWorl
end
world:set(component, jecs.OnAdd, on_add)
end
local max = #listeners + 1
listeners[max] = fn
table.insert(listeners, fn)
return function()
local n = #listeners
listeners[max] = listeners[n]
local i = table.find(listeners, fn)
listeners[i] = listeners[n]
listeners[n] = nil
end
end
@ -238,11 +238,11 @@ local function observers_add(world: jecs.World & { [string]: any }): PatchedWorl
end
world:set(component, jecs.OnChange, on_change)
end
local max = #listeners + 1
listeners[max] = fn
table.insert(listeners, fn)
return function()
local n = #listeners
listeners[max] = listeners[n]
local i = table.find(listeners, fn)
listeners[i] = listeners[n]
listeners[n] = nil
end
end
@ -261,11 +261,11 @@ local function observers_add(world: jecs.World & { [string]: any }): PatchedWorl
end
world:set(component, jecs.OnRemove, on_remove)
end
local max = #listeners + 1
listeners[max] = fn
table.insert(listeners, fn)
return function()
local n = #listeners
listeners[max] = listeners[n]
local i = table.find(listeners, fn)
listeners[i] = listeners[n]
listeners[n] = nil
end
end