mirror of
https://github.com/morluto/rea
synced 2026-10-26 22:28:27 -04:00
perf(javascript): reduce retained semantic analysis allocations (#1601)
Reduce retained semantic allocations and memoize lexical scope ancestry while preserving semantic identities. Refs #1065 and #1563; the complete-directory memory failure remains open.
This commit is contained in:
@@ -444,6 +444,7 @@ function* collectDefinitionsSteps(
|
||||
}[] = [];
|
||||
yield* traverseJavaScriptAstSteps(program, {
|
||||
enter: (node, parent, readAncestors) => {
|
||||
if (parent !== null) state.parentsByNode.set(node, parent);
|
||||
let parentScope = currentSemanticScope(stack);
|
||||
if (
|
||||
parent !== null &&
|
||||
@@ -493,7 +494,10 @@ function* collectDefinitionsSteps(
|
||||
});
|
||||
}
|
||||
const scope = currentSemanticScope(stack);
|
||||
state.scopeByNode.set(node, scope);
|
||||
// Other nodes inherit the nearest boundary through their AST parents.
|
||||
// Avoid a second full-tree index for the same lexical relationship.
|
||||
if (parent === null || openedScopes.has(node))
|
||||
state.scopeByNode.set(node, scope);
|
||||
collectSemanticCallable({
|
||||
node,
|
||||
parent,
|
||||
|
||||
Reference in New Issue
Block a user