mirror of
https://github.com/imjasonh/nescript
synced 2026-07-08 17:06:04 +00:00
The phased compression driver was computing the schedule/round *index* per iteration and then shifting it left by 2 to get the byte offset (`schedule_one(i << 2)`, `round_one(r << 2)`). The shift compiles to two ASLs per iteration — cheap, but pure dead work since the byte offset is just the previous one + 4. Track the byte offset as the loop counter and bump it by 4 each iteration. The schedule and round APIs already wanted byte offsets, so the call sites also get a touch shorter (no more intermediate `var i: u8 = first_idx + step`). Strict cycle savings are tiny — a handful per iteration — so this is more about not leaving obviously redundant work in the inner loop than a meaningful perf win. Hash output unchanged (still AE9145DB…4E0D for "NES"); no other examples affected; emulator harness 34/34. https://claude.ai/code/session_01FRmSBruVWCufm3LsUVMs8v
24 KiB
24 KiB