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.
This commit is contained in:
Eric Biggers 2021-12-31 16:04:49 -06:00
parent 7e0242d04f
commit 4b7e9029d1

View File

@ -2122,7 +2122,9 @@ deflate_compress_lazy(struct libdeflate_compressor * restrict c,
c->max_search_depth, c->max_search_depth,
next_hashes, next_hashes,
&cur_offset); &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. */ /* No match found. Choose a literal. */
deflate_choose_literal(c, *in_next, &litrunlen); deflate_choose_literal(c, *in_next, &litrunlen);
observe_literal(&c->split_stats, *in_next); observe_literal(&c->split_stats, *in_next);