mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-25 06:24:27 +08:00
A helper object over a Map or Set iterator that is stored and consumed later (const it = set.values().map(f); for (const x of it) ...) stepped the runtime's checked iterator through an adapter generator, boxing each value and resuming two generators per element: 5.1x Node's time on a 100k-element Set. A stage on m.keys(), m.values(), m.entries() (or a Set's), or on Iterator.from(set) or Iterator.from(map), now walks the collection inside the helper's own generator. The walk steps the runtime's native iterator by entry index through the new scr_dyn_collection_iterator_index and reads each key or value with the typed intrinsics. The native iterator keeps the walk live and ends the collection's iteration when it is exhausted or released, so an abandoned or returned helper leaves the collection free to compact. Other helper sources over a Map or Set, and Iterator.from over a Set or Map, use a typed generator over the collection built the same way.