mirror of
https://github.com/rommapp/romm.git
synced 2026-11-30 10:32:57 +01:00
Every chunk was streamed through two independent sets of hashers: one for the RomFile and one accumulating the ROM-level hash. That second set is only meaningful for a multi-file ROM, whose hash spans the concatenation of its top-level files and so cannot be derived from the per-file digests. For a single-file ROM the two sets see identical bytes and produce identical digests, so the ROM-level pass was pure duplicate work. Nested files inside a multi-file ROM were worse: they were fed through throwaway accumulators whose results were discarded at the call site. Make the accumulators optional and skip them where they are not needed, reusing the file's own hashers as the ROM-level values for a single-file ROM. Multi-file top-level files keep the second pass, since theirs is the case that needs it. Measured on a Raspberry Pi 4 against a 134 MB Nintendo 3DS ROM, page cache warmed, best of three, comparing CPU time to exclude contention: 36.5 MB/s -> 60.3 MB/s, a 1.65x speedup, with byte-identical CRC, MD5 and SHA1 at both the file and ROM level. Most libraries are predominantly single-file, so this applies broadly rather than to an edge case. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>