mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-27 06:43:19 +08:00
for-in over a pure index-signature record (`Record<string, number>`) skips keys deleted during the walk by testing each snapshotted key for presence before visiting it. The test built the overflow map's whole key list and searched it with includes() on every visit, so a walk over n keys took O(n^2) time: 200 walks over 2000 keys took 8.7 s, against 31 ms under Node. The test is now recordOvfHas, the overflow map's hashed presence check, which answers the same question in constant time. The new benchmark workload dictionary-walks walks, prunes and merges Record<string, number> dictionaries with for-in and Object.keys/values/ entries. It takes 7.1 s before this change and 23 ms after (Node 116 ms). Corpus program 7011 pins for-in's visit order and its handling of keys deleted, re-added and added during the walk.