Commit 4da9c3e
committed
perf(normalize): eliminate double normalization of params in callParts
callParts() was normalizing all parameters twice — once to calculate
paramLoc via SpanList.range(), then again to build the positional args.
The paramList computed on the first pass is already ASTv2.ExpressionNode[]
and can be passed directly to builder.positional(). Safe because:
- Symbol allocations (allocateFree/allocateNamed) are idempotent — they
check indexOf/cache before allocating, so the second pass was pure waste.
- PositionalArguments stores exprs as readonly — no mutation concern.
- SpanList.range() only reads .loc from the nodes — no stored references.
The duplication dates back to the original 2020 commit (8e11b91) where
paramList was computed for SpanList.range() but then not reused for the
builder, with an identical .map(normalize) call created instead.
Impact (pnpm bench:precompile, prod dist, Apple M1 Max):
- normalize large (33374c): 18.92ms → 17.72ms (6%)
- precompile large: 43.01ms → 41.12ms (4%)1 parent f9ecab5 commit 4da9c3e
1 file changed
Lines changed: 1 addition & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
| 270 | + | |
274 | 271 | | |
275 | 272 | | |
276 | 273 | | |
| |||
0 commit comments