Quenty / NevermoreEngine

ModuleScript loader with reusable and easy unified server-client modules for faster game development on Roblox
https://quenty.github.io/NevermoreEngine/
MIT License
408 stars 124 forks source link

refactor: StateStack perf, typecheck bugfix #481

Open OttoHatt opened 1 month ago

OttoHatt commented 1 month ago

Performance improvements. And, fixes a bug where pushing an invalid value into the StateStack fatally corrupts it (read comment).

local stack = StateStack.new("a", "string")
local clean = stack:PushState("b")
task.defer(stack.PushState, stack, 1)
task.defer(function()
    -- '1' was added to the internal stack.
    -- Cleaning pulls it back up, setting .Value =, throwing inline!
    clean()
    print("New value", stack:GetState())
end)