mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-04 08:04:37 +08:00
A literal integer switch over a number tested min <= x <= max with two ordered compares before converting and round-tripping the discriminant. The round trip alone already rejects every non-matching value once the conversion is frozen: NaN and infinities compare unordered, a frozen out-of-range conversion converts back to a different value, fractions fail, and -0 selects case 0 like strict equality. Cases in [2^31, 2^32) dispatch on i64 instead of fptoui to i32. A discriminant already proven to be an exact integer (int32 slots, x | 0, x >>> 0, counted-loop counters) now selects directly, narrowing to i32 only when its proven range fits. tsc-ts (callgrind, single-threaded): self-check about -0.8 % instructions, mostly switch (node.kind) and token dispatch.