From 08c1eda7fffdee4ebc590a2cc97dc0bde3cc268e Mon Sep 17 00:00:00 2001 From: Sathya Gunasekaran Date: Wed, 1 Mar 2023 16:48:54 +0000 Subject: [PATCH] [hir] Simplify depRoot map Use Identifier as a key, which lets us simplify lookup to no longer require an index access. --- .../src/ReactiveScopes/PropagateScopeDependencies.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts b/compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts index c5a7970793..bdcaacf46b 100644 --- a/compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts +++ b/compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts @@ -272,10 +272,10 @@ function deriveMinimalDependenciesInSubtree( function deriveMinimalDependencies( initialDeps: Set ): Set { - const depRoots = new Map(); + const depRoots = new Map(); for (const dep of initialDeps) { - let root = depRoots.get(dep.identifier.id)?.[1]; + let root = depRoots.get(dep.identifier); const path = dep.path ?? []; if (root == null) { // roots can always be accessed unconditionally in JS @@ -283,7 +283,7 @@ function deriveMinimalDependencies( properties: new Map(), accessType: PropertyAccessType.UnconditionalAccess, }; - depRoots.set(dep.identifier.id, [dep.identifier, root]); + depRoots.set(dep.identifier, root); } let currNode: DependencyNode = root; @@ -314,7 +314,7 @@ function deriveMinimalDependencies( } const results = new Set(); - for (const [_, [rootId, rootNode]] of depRoots) { + for (const [root, rootNode] of depRoots.entries()) { const deps = deriveMinimalDependenciesInSubtree(rootNode); invariant( deps.every( @@ -325,7 +325,7 @@ function deriveMinimalDependencies( for (const dep of deps) { results.add({ - identifier: rootId, + identifier: root, path: dep.relativePath, }); }