From 4b7e9029d1703a0cd0b6746d36c51b127dcce63d Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Fri, 31 Dec 2021 16:04:49 -0600 Subject: [PATCH] deflate_compress: don't use far len 3 matches in lazy compressor It's usually not worth using length 3 matches with a large offset. --- lib/deflate_compress.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/deflate_compress.c b/lib/deflate_compress.c index eea49bd..fe6b9b5 100644 --- a/lib/deflate_compress.c +++ b/lib/deflate_compress.c @@ -2122,7 +2122,9 @@ deflate_compress_lazy(struct libdeflate_compressor * restrict c, c->max_search_depth, next_hashes, &cur_offset); - if (cur_len < DEFLATE_MIN_MATCH_LEN) { + if (cur_len < DEFLATE_MIN_MATCH_LEN || + (cur_len == DEFLATE_MIN_MATCH_LEN && + cur_offset > 8192)) { /* No match found. Choose a literal. */ deflate_choose_literal(c, *in_next, &litrunlen); observe_literal(&c->split_stats, *in_next);