mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-07 08:36:02 -10:00
rd_insert() hands back the chain head it just linked for a position, and the greedy parser (levels 1-3) already used it to skip the match search when there is no earlier occurrence. The lazy parser - levels 4-9, which includes the level-6 screenshot encoder - threw it away and called rd_longest_match() at every position, which reloaded the head from prev[] and returned 0 when it was empty. On noisy input that is about half of all positions: a full call, register saves and the struct loads of the prologue, to learn there was nothing to do. Both parsers now pass the head in and only call when a chain exists; rd_longest_match() starts its walk from it instead of re-reading prev[]. An empty chain returned 0 with no side effects before, so the parse - and the stream - are unchanged. Compressed output is byte-identical to before over the level 0-9 x input chunking x six-input matrix, zlib-wrapped and raw, also under ASan/UBSan; rzip, rpng, archive and encodings sample tests pass; builds C89 without new warnings and for aarch64. screenshot_io_bench, 3840x2160 BGR24 PNG: noise instructions -10.3% (10.37 G -> 9.30 G), best 393 -> 380 ms, median about -4%; gradient unchanged.