Problem
The Phase 8.3f resolution in buildPointsToMap (src/domain/graph/resolver/points-to.ts:187-199) uses three nested for...of loops with no early indexing:
for (const restBinding of objectRestParamBindings) {
for (const paramBinding of paramBindings) {
for (const propBinding of objectPropBindings) {
if (...equality guards...) { ... }
}
}
}
In a large generated or bundled file with many rest-param functions and object literals, the inner-loop body executes on every combination before the equality guards discard most pairs. This is O(|objectRestParamBindings| × |paramBindings| × |objectPropBindings|).
Fix
Pre-index the bindings before the loops:
paramBindings as Map<callee+argIndex, argName[]>
objectPropBindings as Map<objectName, {propName, valueName}[]>
This reduces the lookup to O(n) and avoids the quadratic scan of paramBindings for each rest binding.
Impact
Low risk for current benchmark files (small fixtures). Becomes a performance concern for large real-world codebases with many rest-destructured parameters.
Context
Identified in Greptile review of PR #1331.
Problem
The Phase 8.3f resolution in
buildPointsToMap(src/domain/graph/resolver/points-to.ts:187-199) uses three nestedfor...ofloops with no early indexing:In a large generated or bundled file with many rest-param functions and object literals, the inner-loop body executes on every combination before the equality guards discard most pairs. This is O(|objectRestParamBindings| × |paramBindings| × |objectPropBindings|).
Fix
Pre-index the bindings before the loops:
paramBindingsasMap<callee+argIndex, argName[]>objectPropBindingsasMap<objectName, {propName, valueName}[]>This reduces the lookup to O(n) and avoids the quadratic scan of
paramBindingsfor each rest binding.Impact
Low risk for current benchmark files (small fixtures). Becomes a performance concern for large real-world codebases with many rest-destructured parameters.
Context
Identified in Greptile review of PR #1331.