Commit 2b6ee67
committed
perf(semantic): pre-reserve unresolved_references using Stats::references
The unresolved_references Vec grows from 0 with default doubling, requiring
~13 reallocations to reach the typical ~5k references on a moderately-sized
TypeScript file. Stats already knows the count up-front (or computes it in
Stats::count); pre-reserving eliminates the growth reallocations.
Benchmark (cargo bench --bench semantic):
RadixUI.jsx (3KB JSX): 3.155 µs -> 3.051 µs (-3.3%)
react.development.js: 136.47 µs -> 134.93 µs (-1.1%)
cal.com.tsx (1MB TSX): 2.7414 ms -> 2.7055 ms (-1.3%)
binder.ts (193KB TS): 314.90 µs -> 312.15 µs (-0.9%)
All intervals non-overlapping on Criterion.1 parent 180aa9f commit 2b6ee67
2 files changed
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
| 326 | + | |
326 | 327 | | |
327 | 328 | | |
328 | 329 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
19 | 26 | | |
20 | 27 | | |
21 | 28 | | |
| |||
0 commit comments