mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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)
This commit is contained in:
1 parent
2b47cac5fd
commit
b1ee356805
1 file changed
+9
-14
@@ -119,23 +119,18 @@ export function inferReactiveIdentifiers(
|
||||
reactivityMap.set(param.identifier, true);
|
||||
}
|
||||
const actuallyReactiveScopes = new Set<ReactiveScope>();
|
||||
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<Identifier>();
|
||||
|
||||
Reference in new issue
Block a user