mirror of
https://github.com/AmberGraceRblx/luau-promise.git
synced 2025-04-24 15:50:01 +00:00
Avoid reallocating another table for the _consumers() metatable, leading to a 5%-10% speed up of the trivial Promise.new(function() end) case
This commit is contained in:
parent
f0fd3020fd
commit
ffd4cd94a1
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_FUNCTION = "Please pass a handler function to %s!"
|
||||
|
||||
local MODE_KEY_METATABLE = {
|
||||
__mode = "k";
|
||||
}
|
||||
|
||||
local RunService = game:GetService("RunService")
|
||||
|
||||
--[[
|
||||
|
@ -130,9 +134,7 @@ function Promise.new(callback, parent)
|
|||
-- cancellation propagation.
|
||||
_parent = parent,
|
||||
|
||||
_consumers = setmetatable({}, {
|
||||
__mode = "k";
|
||||
}),
|
||||
_consumers = setmetatable({}, MODE_KEY_METATABLE),
|
||||
}
|
||||
|
||||
if parent and parent._status == Promise.Status.Started then
|
||||
|
|
Loading…
Reference in a new issue