Commit 086ac8c
committed
perf(concat-source): apply indexed-loop pattern to source(), size(), updateHash()
Same V8 fast-path principle as the buffers() change in c29e061 — keep
array iteration integer-indexed and the element type monomorphic so
the optimizer doesn't fall off the cliff.
A/B/A wall-clock medians (es6-promise.js fixture, 3 alternating runs
so far; bg task still running):
concat-source: source() (10 raw) 923 075 -> 971 196 ops/s (+5%)
concat-source: size() 108 429 -> 692 935 ops/s (+6.4x)
concat-source: updateHash() ~wash (within rme)
The size() bench's 6.4x jump comes from the bench shape: it builds a
fresh 4-child mixed ConcatSource per task and calls size() ten times.
With for-of, each call allocates an iterator; the size() body itself
is so cheap that the iterator setup dominates. for-i removes that
overhead entirely.
source() is more modest because the body work (string concat per
child) outweighs iterator setup. updateHash() is wash for the same
reason — `child.updateHash(hash)` is much heavier than the loop.
Tests still green; lint clean.
https://claude.ai/code/session_01EHhGq9PRFRGefVtwwasCqZ1 parent c29e061 commit 086ac8c
1 file changed
Lines changed: 12 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
134 | 136 | | |
135 | | - | |
136 | | - | |
| 137 | + | |
| 138 | + | |
137 | 139 | | |
138 | 140 | | |
139 | 141 | | |
140 | 142 | | |
141 | 143 | | |
142 | 144 | | |
| 145 | + | |
| 146 | + | |
143 | 147 | | |
144 | | - | |
145 | | - | |
| 148 | + | |
| 149 | + | |
146 | 150 | | |
147 | 151 | | |
148 | 152 | | |
| |||
315 | 319 | | |
316 | 320 | | |
317 | 321 | | |
| 322 | + | |
| 323 | + | |
318 | 324 | | |
319 | | - | |
320 | | - | |
321 | | - | |
| 325 | + | |
| 326 | + | |
322 | 327 | | |
323 | 328 | | |
324 | 329 | | |
| |||
0 commit comments