From 9ace23470f6dd151d7e532c989ebc4cd40b33c92 Mon Sep 17 00:00:00 2001 From: centauri <83140718+centau@users.noreply.github.com> Date: Tue, 2 Sep 2025 03:12:19 +0100 Subject: [PATCH] Use generalized iteration everywhere Closes #55 --- src/apply.luau | 6 +++--- src/graph.luau | 2 +- src/implicit_effect.luau | 4 ++-- src/spring.luau | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/apply.luau b/src/apply.luau index 85020ff..c05fedf 100644 --- a/src/apply.luau +++ b/src/apply.luau @@ -133,8 +133,8 @@ local function apply(instance: T & Instance, properties: { [unknown]: unknown ;(instance :: any)[event_name]:Connect(event_listener) end - for _, queued in next, actions do - for _, callback in next, queued do + for _, queued in actions do + for _, callback in queued do callback(instance) end end @@ -149,7 +149,7 @@ local function apply(instance: T & Instance, properties: { [unknown]: unknown end table.clear(events) - for _, queued in next, actions do table.clear(queued) end + for _, queued in actions do table.clear(queued) end caches.parent = nil if flags.strict then table.clear(nested_debug) end table.clear(nested_stack) diff --git a/src/graph.luau b/src/graph.luau index 4834455..fd22489 100644 --- a/src/graph.luau +++ b/src/graph.luau @@ -93,7 +93,7 @@ end local function flush_cleanups(node: Node) if node.cleanups then - for _, fn in next, node.cleanups do + for _, fn in node.cleanups do local ok, err: string? = xpcall(fn, debug.traceback) if not ok then error(`cleanup error: {err}`, 0) end end diff --git a/src/implicit_effect.luau b/src/implicit_effect.luau index 7dbd2f7..6fed9bc 100644 --- a/src/implicit_effect.luau +++ b/src/implicit_effect.luau @@ -47,7 +47,7 @@ local function update_children_effect(p: { cur_children_set[child] = nil -- remove child from cache if it was already in cache end elseif type(child) == "table" then - for _, child in next, child do + for _, child in child do process_child(child) end elseif type(child) == "function" then @@ -70,7 +70,7 @@ local function update_children_effect(p: { process_child(new_children) - for child in next, cur_children_set do + for child in cur_children_set do child.Parent = nil -- unparent all children that weren't in the new children set end diff --git a/src/spring.luau b/src/spring.luau index 6e1ce1e..303ed74 100644 --- a/src/spring.luau +++ b/src/spring.luau @@ -233,7 +233,7 @@ local function spring(source: () -> T, period: number?, damping_ratio: number end local function step_springs(dt: number) - for data in next, springs do + for data in springs do local k, c, x0_123, x1_123, u_123, x0_456, x1_456, u_456 =