mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-02 05:39:05 +00:00
The block decoder previously copied literals through variable-length memcpy calls and expanded every match with word loops that carried an overcopy fallback in each branch. Real page blocks decode as millions of tiny sequences, so per-sequence overhead dominated restore time. Decode short literal runs and in-token matches with blind fixed-width copies whose margin checks subsume the exact bounds checks they replace. Expand small repeating periods into pattern-word stores, copy distant long matches with one exact memcpy, and propagate the rare non-power-of-two short offsets bytewise. Page corpora restore 13% to 19% faster and text around twice as fast, while compressor output stays byte-for-byte unchanged. Replace the fuzz test with a differential property suite which round-trips generated inputs, validates blocks with an independent format walker, rejects wrong-size outputs, and decodes corrupted and truncated blocks. A light version runs as a normal unit test; the exhaustive version runs when GHOSTTY_LZ4_SLOW is set. An AGENTS.md records the benchmarking, testing, and verification workflow for this directory.