From b1ee3568051c2edde1cd05721fae8b2dc7b9fc39 Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Tue, 14 Feb 2023 15:24:01 -0800 Subject: [PATCH] InferReactiveIdentifiers: fixpoint iteration is now unnecessary I removed fixpoint iteration and all tests pass, which matches my intuition that it's really that we need strictly two passes. Removing to simplify and for performance (avoid unnecessary extra visits of the ast) --- .../InferReactiveIdentifiers.ts | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/compiler/forget/src/ReactiveScopes/InferReactiveIdentifiers.ts b/compiler/forget/src/ReactiveScopes/InferReactiveIdentifiers.ts index f080fba8f0..f39cde96e9 100644 --- a/compiler/forget/src/ReactiveScopes/InferReactiveIdentifiers.ts +++ b/compiler/forget/src/ReactiveScopes/InferReactiveIdentifiers.ts @@ -119,23 +119,18 @@ export function inferReactiveIdentifiers( reactivityMap.set(param.identifier, true); } const actuallyReactiveScopes = new Set(); - let prevScopesSize = -1; - // TODO(mofeiZ): avoid fixpoint iteration - while (actuallyReactiveScopes.size > prevScopesSize) { - prevScopesSize = actuallyReactiveScopes.size; - visitReactiveFunction(fn, visitor, reactivityMap); + visitReactiveFunction(fn, visitor, reactivityMap); - for (const [id, value] of reactivityMap) { - const { scope } = id; - if (value && scope != null) { - actuallyReactiveScopes.add(scope); - } + for (const [id, value] of reactivityMap) { + const { scope } = id; + if (value && scope != null) { + actuallyReactiveScopes.add(scope); } - for (const [id, _] of reactivityMap) { - if (id.scope && actuallyReactiveScopes.has(id.scope)) { - reactivityMap.set(id, true); - } + } + for (const [id, _] of reactivityMap) { + if (id.scope && actuallyReactiveScopes.has(id.scope)) { + reactivityMap.set(id, true); } } const result = new Set();