util.promise: Remove references to callbacks after settling promise

This is to help the garbage collector.
This commit is contained in:
Kim Alvefur 2018-12-30 03:24:54 +01:00
parent 92445d93df
commit 2d28fb93b4

View file

@ -49,6 +49,9 @@ local function promise_settle(promise, new_state, new_next, cbs, value)
for _, cb in ipairs(cbs) do
cb(value);
end
-- No need to keep references to callbacks
promise._pending_on_fulfilled = nil;
promise._pending_on_rejected = nil;
return true;
end