mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-08 08:44:37 +08:00
scr_u16_to_byte_c and scr_byte_to_u16_c run on every native charCodeAt, substring and search result. Most calls are the identity of an ASCII string or a hit in the cached ASCII run, but every call paid the prologue of the full walk. Those two cases are now static inline, and the walk is a separate function. A forward access up to 4 KiB past the cached run first extends the run word by word (with 256 bytes of lookahead) instead of walking from the cursor and re-centring a 128-byte window, which made a scanner reading a long ASCII stretch of a non-ASCII text walk repeatedly.