mirror of
https://github.com/AmberGraceRblx/luau-promise.git
synced 2025-04-24 15:50:01 +00:00
Merge pull request #19 from Quenty/users/quenty/avoid_realloc
Avoid reallocating another table for the _consumers() metatable, lead…
This commit is contained in:
commit
01499e5b7f
1 changed files with 5 additions and 3 deletions
|
@ -8,6 +8,10 @@ local ERROR_NON_PROMISE_IN_LIST = "Non-promise value passed into %s at index %s"
|
||||||
local ERROR_NON_LIST = "Please pass a list of promises to %s"
|
local ERROR_NON_LIST = "Please pass a list of promises to %s"
|
||||||
local ERROR_NON_FUNCTION = "Please pass a handler function to %s!"
|
local ERROR_NON_FUNCTION = "Please pass a handler function to %s!"
|
||||||
|
|
||||||
|
local MODE_KEY_METATABLE = {
|
||||||
|
__mode = "k";
|
||||||
|
}
|
||||||
|
|
||||||
local RunService = game:GetService("RunService")
|
local RunService = game:GetService("RunService")
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
|
@ -130,9 +134,7 @@ function Promise.new(callback, parent)
|
||||||
-- cancellation propagation.
|
-- cancellation propagation.
|
||||||
_parent = parent,
|
_parent = parent,
|
||||||
|
|
||||||
_consumers = setmetatable({}, {
|
_consumers = setmetatable({}, MODE_KEY_METATABLE),
|
||||||
__mode = "k";
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if parent and parent._status == Promise.Status.Started then
|
if parent and parent._status == Promise.Status.Started then
|
||||||
|
|
Loading…
Reference in a new issue