From 320c306db37de99efabe426eab964efbca28a964 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sat, 1 Jan 2022 19:49:14 -0600 Subject: [PATCH] hc_matchfinder: make skip_positions() return void --- lib/deflate_compress.c | 48 ++++++++++++++++++++++-------------------- lib/hc_matchfinder.h | 8 ++----- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/lib/deflate_compress.c b/lib/deflate_compress.c index 808b77e..7dc7fac 100644 --- a/lib/deflate_compress.c +++ b/lib/deflate_compress.c @@ -2182,13 +2182,13 @@ deflate_compress_greedy(struct libdeflate_compressor * restrict c, /* Match found. */ deflate_choose_match(c, length, offset, &seq); observe_match(&c->split_stats, length); - in_next = hc_matchfinder_skip_positions( - &c->p.g.hc_mf, - &in_cur_base, - in_next + 1, - in_end, - length - 1, - next_hashes); + hc_matchfinder_skip_positions(&c->p.g.hc_mf, + &in_cur_base, + in_next + 1, + in_end, + length - 1, + next_hashes); + in_next += length; } else { /* No match found. */ deflate_choose_literal(c, *in_next, seq); @@ -2295,13 +2295,13 @@ deflate_compress_lazy_generic(struct libdeflate_compressor * restrict c, if (cur_len >= nice_len) { deflate_choose_match(c, cur_len, cur_offset, &seq); - in_next = hc_matchfinder_skip_positions( - &c->p.g.hc_mf, - &in_cur_base, - in_next, - in_end, - cur_len - 1, - next_hashes); + hc_matchfinder_skip_positions(&c->p.g.hc_mf, + &in_cur_base, + in_next, + in_end, + cur_len - 1, + next_hashes); + in_next += cur_len - 1; continue; } @@ -2384,14 +2384,16 @@ deflate_compress_lazy_generic(struct libdeflate_compressor * restrict c, */ deflate_choose_match(c, cur_len, cur_offset, &seq); - if (cur_len > 3) - in_next = hc_matchfinder_skip_positions( + if (cur_len > 3) { + hc_matchfinder_skip_positions( &c->p.g.hc_mf, &in_cur_base, in_next, in_end, cur_len - 3, next_hashes); + in_next += cur_len - 3; + } } else { /* !lazy2 */ /* * No better match at the next position. Output @@ -2399,13 +2401,13 @@ deflate_compress_lazy_generic(struct libdeflate_compressor * restrict c, */ deflate_choose_match(c, cur_len, cur_offset, &seq); - in_next = hc_matchfinder_skip_positions( - &c->p.g.hc_mf, - &in_cur_base, - in_next, - in_end, - cur_len - 2, - next_hashes); + hc_matchfinder_skip_positions(&c->p.g.hc_mf, + &in_cur_base, + in_next, + in_end, + cur_len - 2, + next_hashes); + in_next += cur_len - 2; } /* Check if it's time to output another block. */ } while (in_next < in_max_block_end && diff --git a/lib/hc_matchfinder.h b/lib/hc_matchfinder.h index 23daead..9f1f799 100644 --- a/lib/hc_matchfinder.h +++ b/lib/hc_matchfinder.h @@ -357,10 +357,8 @@ out: * The precomputed hash codes for the sequence beginning at @in_next. * These will be used and then updated with the precomputed hashcodes for * the sequence beginning at @in_next + @count. - * - * Returns @in_next + @count. */ -static forceinline const u8 * +static forceinline void hc_matchfinder_skip_positions(struct hc_matchfinder * const restrict mf, const u8 ** const restrict in_base_p, const u8 *in_next, @@ -374,7 +372,7 @@ hc_matchfinder_skip_positions(struct hc_matchfinder * const restrict mf, u32 remaining = count; if (unlikely(count + 5 > in_end - in_next)) - return &in_next[count]; + return; cur_pos = in_next - *in_base_p; hash3 = next_hashes[0]; @@ -399,8 +397,6 @@ hc_matchfinder_skip_positions(struct hc_matchfinder * const restrict mf, prefetchw(&mf->hash4_tab[hash4]); next_hashes[0] = hash3; next_hashes[1] = hash4; - - return in_next; } #endif /* LIB_HC_MATCHFINDER_H */