Merge pull request #19 from Quenty/users/quenty/avoid_realloc

Avoid reallocating another table for the _consumers() metatable, lead…
This commit is contained in:
eryn L. K 2020-03-29 18:16:49 -04:00 committed by GitHub
commit 01499e5b7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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