mirror of
https://github.com/GerbilSoft/zlib-ng.git
synced 2025-06-18 11:35:35 -04:00
Clean up insert_match() in deflate_medium
This commit is contained in:
parent
322753f36e
commit
56d3d9851a
@ -45,10 +45,12 @@ static void insert_match(deflate_state *s, struct match match) {
|
|||||||
if (UNLIKELY(s->lookahead <= (unsigned int)(match.match_length + WANT_MIN_MATCH)))
|
if (UNLIKELY(s->lookahead <= (unsigned int)(match.match_length + WANT_MIN_MATCH)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* string at strstart already in table */
|
||||||
|
match.strstart++;
|
||||||
|
match.match_length--;
|
||||||
|
|
||||||
/* matches that are not long enough we need to emit as literals */
|
/* matches that are not long enough we need to emit as literals */
|
||||||
if (LIKELY(match.match_length < WANT_MIN_MATCH)) {
|
if (LIKELY(match.match_length < WANT_MIN_MATCH - 1)) {
|
||||||
match.strstart++;
|
|
||||||
match.match_length--;
|
|
||||||
if (UNLIKELY(match.match_length > 0)) {
|
if (UNLIKELY(match.match_length > 0)) {
|
||||||
if (match.strstart >= match.orgstart) {
|
if (match.strstart >= match.orgstart) {
|
||||||
if (match.strstart + match.match_length - 1 >= match.orgstart) {
|
if (match.strstart + match.match_length - 1 >= match.orgstart) {
|
||||||
@ -63,33 +65,18 @@ static void insert_match(deflate_state *s, struct match match) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert new strings in the hash table. */
|
/* Insert into hash table. */
|
||||||
if (s->lookahead >= WANT_MIN_MATCH) {
|
if (LIKELY(match.strstart >= match.orgstart)) {
|
||||||
match.match_length--; /* string at strstart already in table */
|
if (LIKELY(match.strstart + match.match_length - 1 >= match.orgstart)) {
|
||||||
match.strstart++;
|
insert_string(s, match.strstart, match.match_length);
|
||||||
|
} else {
|
||||||
if (LIKELY(match.strstart >= match.orgstart)) {
|
insert_string(s, match.strstart, match.orgstart - match.strstart + 1);
|
||||||
if (LIKELY(match.strstart + match.match_length - 1 >= match.orgstart)) {
|
|
||||||
insert_string(s, match.strstart, match.match_length);
|
|
||||||
} else {
|
|
||||||
insert_string(s, match.strstart, match.orgstart - match.strstart + 1);
|
|
||||||
}
|
|
||||||
} else if (match.orgstart < match.strstart + match.match_length) {
|
|
||||||
insert_string(s, match.orgstart, match.strstart + match.match_length - match.orgstart);
|
|
||||||
}
|
}
|
||||||
match.strstart += match.match_length;
|
} else if (match.orgstart < match.strstart + match.match_length) {
|
||||||
match.match_length = 0;
|
insert_string(s, match.orgstart, match.strstart + match.match_length - match.orgstart);
|
||||||
} else {
|
|
||||||
match.strstart += match.match_length;
|
|
||||||
match.match_length = 0;
|
|
||||||
|
|
||||||
if (match.strstart >= (STD_MIN_MATCH - 2))
|
|
||||||
quick_insert_string(s, match.strstart + 2 - STD_MIN_MATCH);
|
|
||||||
|
|
||||||
/* If lookahead < WANT_MIN_MATCH, ins_h is garbage, but it does not
|
|
||||||
* matter since it will be recomputed at next deflate call.
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
match.strstart += match.match_length;
|
||||||
|
match.match_length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fizzle_matches(deflate_state *s, struct match *current, struct match *next) {
|
static void fizzle_matches(deflate_state *s, struct match *current, struct match *next) {
|
||||||
|
Loading…
Reference in New Issue
Block a user