mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-25 06:24:27 +08:00
String construction copied every span with a libc memcpy call, and scr_str_new scanned the copied bytes for ASCII in a second pass. Spans of at most 16 bytes (identifiers, map keys, number text) now move as two overlapping fixed-size words, and scr_str_new tests those same words for ASCII, so the fact is free for short strings; longer spans keep the bulk copy and a chunked scan that stops at the first non-ASCII byte. A scan that proves a heap string ASCII now also drops its index-cache entry: a proven-ASCII string never owns one, because every UTF-16 mapper answers it by identity and re-checks the header bit after extending an index. Releasing such a string therefore skips the cache purge, and a large text proven ASCII once (a JSON document's length, a source file) no longer keeps every later string release walking the cache. Immortal strings cannot record the bit and keep their entries as before.