mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-24 06:14:01 +08:00
`s += x` (canonically `s = s + x`) on a string binding took a retained snapshot of `s`, evaluated the suffix, released the binding's value so the snapshot became unique, concatenated (appending in place), and released the snapshot: a retain and two releases around every append. tsc-ts's typeListKey alone made 3.4M such releases (plus 2.1M on literal temps). When the binding is an unboxed local that the suffix does not mention, nothing but this function's own expressions can read or write it, so reading it after the suffix gives the left side's value. The old value now moves into scr_str_concat_move / scr_str_concat_mixed_move, which consume their head (appending in place when it is unique), and the result takes its place in the binding: one runtime call instead of four. Boxed bindings, suffixes that read the local, and expression-position updates keep the general path. Corpus 4562 covers aliases that must keep their value, literal heads, number suffixes, throwing suffixes, self-reading suffixes, expression position, captured bindings, and long ASCII and non-ASCII appends. tsc-ts self-check (median of 9, interleaved): 1.854 -> 1.804 s (-2.7%), check 1.471 -> 1.428 s.