From: Hans Kristian Rosbach Date: Mon, 10 May 2021 16:29:40 +0000 (+0200) Subject: Remove support for STD_MIN_MATCH != 3. X-Git-Tag: 2.1.0-beta1~574 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=94fd14ede7c17f88edd5bccb620ec4fea2dd0dbb;p=thirdparty%2Fzlib-ng.git Remove support for STD_MIN_MATCH != 3. It has always been broken and untested anyways. --- diff --git a/deflate.c b/deflate.c index 73cd58a44..87ab64629 100644 --- a/deflate.c +++ b/deflate.c @@ -1228,15 +1228,6 @@ void Z_INTERNAL fill_window(deflate_state *s) { unsigned int str = s->strstart - s->insert; if (str >= 1) functable.quick_insert_string(s, str + 2 - STD_MIN_MATCH); -#if STD_MIN_MATCH != 3 - while (s->insert) { - functable.quick_insert_string(s, str); - str++; - s->insert--; - if (s->lookahead + s->insert < STD_MIN_MATCH) - break; - } -#else unsigned int count; if (UNLIKELY(s->lookahead == 1)) { count = s->insert - 1; @@ -1247,7 +1238,6 @@ void Z_INTERNAL fill_window(deflate_state *s) { functable.insert_string(s, str, count); s->insert -= count; } -#endif } /* If the whole input has less than STD_MIN_MATCH bytes, ins_h is garbage, * but this is not important since only literal bytes will be emitted. diff --git a/deflate_fast.c b/deflate_fast.c index 074e9676b..4142a7aa4 100644 --- a/deflate_fast.c +++ b/deflate_fast.c @@ -76,11 +76,8 @@ Z_INTERNAL block_state deflate_fast(deflate_state *s, int flush) { s->strstart += match_len; } else { s->strstart += match_len; -#if STD_MIN_MATCH != 3 - functable.insert_string(s, s->strstart + 2 - STD_MIN_MATCH, STD_MIN_MATCH - 2); -#else functable.quick_insert_string(s, s->strstart + 2 - STD_MIN_MATCH); -#endif + /* If lookahead < STD_MIN_MATCH, ins_h is garbage, but it does not * matter since it will be recomputed at next deflate call. */ diff --git a/deflate_medium.c b/deflate_medium.c index 71eb48350..c8d3e7701 100644 --- a/deflate_medium.c +++ b/deflate_medium.c @@ -85,12 +85,10 @@ static void insert_match(deflate_state *s, struct match match) { } else { match.strstart += match.match_length; match.match_length = 0; + if (match.strstart >= (STD_MIN_MATCH - 2)) -#if STD_MIN_MATCH != 3 - functable.insert_string(s, match.strstart + 2 - STD_MIN_MATCH, STD_MIN_MATCH - 2); -#else functable.quick_insert_string(s, match.strstart + 2 - STD_MIN_MATCH); -#endif + /* If lookahead < WANT_MIN_MATCH, ins_h is garbage, but it does not * matter since it will be recomputed at next deflate call. */