diff options
author | Nathan Moinvaziri <nathan@nathanm.com> | 2020-06-04 11:17:04 -0700 |
---|---|---|
committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2020-06-27 16:24:14 +0200 |
commit | 4fbbf00ce043041e897042ebdede3e3e45379e1e (patch) | |
tree | fdc2f03b80e9073a2038efdf9cfc302c67956079 /deflate_fast.c | |
parent | 738a6e5b07c0495b8652c77b4879145c083ea49f (diff) |
Move check for hash_head != 0 directly after quick_insert_string.
Diffstat (limited to 'deflate_fast.c')
-rw-r--r-- | deflate_fast.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/deflate_fast.c b/deflate_fast.c index 92a091f..3a2dc4d 100644 --- a/deflate_fast.c +++ b/deflate_fast.c @@ -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); |