summaryrefslogtreecommitdiff
path: root/deflate_medium.c
diff options
context:
space:
mode:
authorNathan Moinvaziri <nathan@nathanm.com>2020-06-04 12:57:24 -0700
committerHans Kristian Rosbach <hk-github@circlestorm.org>2020-06-27 16:24:14 +0200
commit712dd227049ea95fc6a43f00daab64c5490e1af2 (patch)
tree8d6d1e712095ce42e03f63e4594a7fe2784777dd /deflate_medium.c
parent203ddfc7455de523a91fdac2acb1da9ddfdf31ce (diff)
Only set current_match to literal if hash_head == 0.
Diffstat (limited to 'deflate_medium.c')
-rw-r--r--deflate_medium.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/deflate_medium.c b/deflate_medium.c
index d0d8ed6..c043537 100644
--- a/deflate_medium.c
+++ b/deflate_medium.c
@@ -196,16 +196,12 @@ ZLIB_INTERNAL block_state deflate_medium(deflate_state *s, int flush) {
if (next_match.match_length > 0) {
current_match = next_match;
next_match.match_length = 0;
-
} else {
hash_head = 0;
if (s->lookahead >= MIN_MATCH) {
hash_head = functable.quick_insert_string(s, s->strstart);
}
- /* set up the initial match to be a 1 byte literal */
- current_match.match_start = 0;
- current_match.match_length = 1;
current_match.strstart = s->strstart;
current_match.orgstart = current_match.strstart;
@@ -226,6 +222,10 @@ ZLIB_INTERNAL block_state deflate_medium(deflate_state *s, int flush) {
/* this can happen due to some restarts */
current_match.match_length = 1;
}
+ } else {
+ /* Set up the match to be a 1 byte literal */
+ current_match.match_start = 0;
+ current_match.match_length = 1;
}
}
@@ -236,9 +236,6 @@ ZLIB_INTERNAL block_state deflate_medium(deflate_state *s, int flush) {
s->strstart = current_match.strstart + current_match.match_length;
hash_head = functable.quick_insert_string(s, s->strstart);
- /* set up the initial match to be a 1 byte literal */
- next_match.match_start = 0;
- next_match.match_length = 1;
next_match.strstart = s->strstart;
next_match.orgstart = next_match.strstart;
@@ -260,9 +257,13 @@ ZLIB_INTERNAL block_state deflate_medium(deflate_state *s, int flush) {
next_match.match_length = 1;
else
fizzle_matches(s, &current_match, &next_match);
+ } else {
+ /* Set up the match to be a 1 byte literal */
+ next_match.match_start = 0;
+ next_match.match_length = 1;
}
- s->strstart = current_match.strstart;
+ s->strstart = current_match.strstart;
} else {
next_match.match_length = 0;
}