mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-04 08:04:37 +08:00
buf.write(string, 'utf16le' | 'latin1' | 'ascii') decoded one UTF-8 code point per step. tsc-ts converts every source file to UTF-16 this way (toCodeUnits), so the per-character loop showed up in the profile. Eight-byte ASCII runs whose units all fit the remaining budget are now widened (utf16le) or copied directly; any other position, and a tail that would cross the budget, takes the unchanged per-code-point path, so truncation at a unit or surrogate boundary is exactly as before.