mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-07 08:33:50 +08:00
Indexing a value typed unknown with a number, such as `items[i]` on an unknown[], converted the index to a string and looked it up as a property key, and `items.length` read the property by name and boxed the result. In a loop over an unknown[] that costs a string allocation, a key parse and a number box per iteration. The computed-read and `length` helpers the class dispatch generates are now marked for a numeric fast path. A call to one of them with a number index first asks the runtime for the element of a dyn array or a live array capsule (scr_dyn_index_get), and a `length` read checked as a number asks for the array's length (scr_dyn_array_length). The key string is built and the helper runs only when the receiver is anything else, so objects, strings, proxies, class instances, holes and out-of-range or non-index numbers keep the keyed path.