]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Move check for hash_head != 0 directly after quick_insert_string.
authorNathan Moinvaziri <nathan@nathanm.com>
Thu, 4 Jun 2020 18:17:04 +0000 (11:17 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Sat, 27 Jun 2020 14:24:14 +0000 (16:24 +0200)
deflate_fast.c

index 92a091f7f8cd5915a6fa79e385138c15c8ae356a..3a2dc4d26c08e2023293a4ac08296dc6f6d0343b 100644 (file)
@@ -38,22 +38,22 @@ ZLIB_INTERNAL block_state deflate_fast(deflate_state *s, int flush) {
         /* Insert the string window[strstart .. strstart+2] in the
          * dictionary, and set hash_head to the head of the hash chain:
          */
-        hash_head = NIL;
+        s->match_length = 0;
         if (s->lookahead >= MIN_MATCH) {
             hash_head = functable.quick_insert_string(s, s->strstart);
-        }
-
-        /* Find the longest match, discarding those <= prev_length.
-         * At this point we have always match_length < MIN_MATCH
-         */
-        if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
-            /* To simplify the code, we prevent matches with the string
-             * of window index 0 (in particular we have to avoid a match
-             * of the string with itself at the start of the input file).
+            /* Find the longest match, discarding those <= prev_length.
+             * At this point we have always match_length < MIN_MATCH
              */
-            s->match_length = functable.longest_match(s, hash_head);
-            /* longest_match() sets match_start */
+            if (hash_head != 0 && s->strstart - hash_head <= MAX_DIST(s)) {
+                /* To simplify the code, we prevent matches with the string
+                 * of window index 0 (in particular we have to avoid a match
+                 * of the string with itself at the start of the input file).
+                 */
+                s->match_length = functable.longest_match(s, hash_head);
+                /* longest_match() sets match_start */
+            }
         }
+
         if (s->match_length >= MIN_MATCH) {
             check_match(s, s->strstart, s->match_start, s->match_length);