@samitouri / QOS-React / commits / b1ee356805

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)

Joe Savona committed Feb 14, 2023 at 15:24 UTC b1ee3568051c2edde1cd05721fae8b2dc7b9fc39
1 file changed +9 -14
compiler/forget/src/ReactiveScopes/InferReactiveIdentifiers.ts
+9 -14
@@ -119,23 +119,18 @@ export function inferReactiveIdentifiers(
119 reactivityMap.set(param.identifier, true);
120 }
121 const actuallyReactiveScopes = new Set<ReactiveScope>();
122 - let prevScopesSize = -1;
122
124 - // TODO(mofeiZ): avoid fixpoint iteration
125 - while (actuallyReactiveScopes.size > prevScopesSize) {
126 - prevScopesSize = actuallyReactiveScopes.size;
127 - visitReactiveFunction(fn, visitor, reactivityMap);
123 + visitReactiveFunction(fn, visitor, reactivityMap);
124
129 - for (const [id, value] of reactivityMap) {
130 - const { scope } = id;
131 - if (value && scope != null) {
132 - actuallyReactiveScopes.add(scope);
133 - }
125 + for (const [id, value] of reactivityMap) {
126 + const { scope } = id;
127 + if (value && scope != null) {
128 + actuallyReactiveScopes.add(scope);
129 }
135 - for (const [id, _] of reactivityMap) {
136 - if (id.scope && actuallyReactiveScopes.has(id.scope)) {
137 - reactivityMap.set(id, true);
138 - }
130 + }
131 + for (const [id, _] of reactivityMap) {
132 + if (id.scope && actuallyReactiveScopes.has(id.scope)) {
133 + reactivityMap.set(id, true);
134 }
135 }
136 const result = new Set<Identifier>();