diff options
| author | Hans Kristian Rosbach <hk-git@circlestorm.org> | 2026-03-12 15:32:09 +0100 |
|---|---|---|
| committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2026-03-15 01:05:20 +0100 |
| commit | af11e6577df73847010d274c77aba5d4442d846e (patch) | |
| tree | 356027f6d3ea1e571ad86f3247bf91a2a8580794 | |
| parent | 98712c1eee5ca6416a00c39f34279d5c49b92f13 (diff) | |
| download | Project-Tick-af11e6577df73847010d274c77aba5d4442d846e.tar.gz Project-Tick-af11e6577df73847010d274c77aba5d4442d846e.zip | |
- Add local variable match_len in emit_match to avoid extra lookups from struct.
- Move s->lookahead decrement to top of function, both branches of the function
does it and they don't care when it is done.
| -rw-r--r-- | deflate_medium.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/deflate_medium.c b/deflate_medium.c index f67e1b60e7..dfb5e92cc0 100644 --- a/deflate_medium.c +++ b/deflate_medium.c @@ -22,23 +22,24 @@ struct match { static int emit_match(deflate_state *s, struct match match) { int bflush = 0; + uint32_t match_len = match.match_length; + + /* None of the below functions care about s->lookahead, so decrement it early */ + s->lookahead -= match_len; /* matches that are not long enough we need to emit as literals */ - if (match.match_length < WANT_MIN_MATCH) { - while (match.match_length) { + if (match_len < WANT_MIN_MATCH) { + while (match_len) { bflush += zng_tr_tally_lit(s, s->window[match.strstart]); - s->lookahead--; + match_len--; match.strstart++; - match.match_length--; } return bflush; } - check_match(s, match.strstart, match.match_start, match.match_length); - - bflush += zng_tr_tally_dist(s, match.strstart - match.match_start, match.match_length - STD_MIN_MATCH); + check_match(s, match.strstart, match.match_start, match_len); - s->lookahead -= match.match_length; + bflush += zng_tr_tally_dist(s, match.strstart - match.match_start, match_len - STD_MIN_MATCH); return bflush; } |
