hc_matchfinder: make skip_positions() return void

This commit is contained in:
Eric Biggers 2022-01-01 19:49:14 -06:00
parent c16ba46008
commit 320c306db3
2 changed files with 27 additions and 29 deletions

View File

@ -2182,13 +2182,13 @@ deflate_compress_greedy(struct libdeflate_compressor * restrict c,
/* Match found. */ /* Match found. */
deflate_choose_match(c, length, offset, &seq); deflate_choose_match(c, length, offset, &seq);
observe_match(&c->split_stats, length); observe_match(&c->split_stats, length);
in_next = hc_matchfinder_skip_positions( hc_matchfinder_skip_positions(&c->p.g.hc_mf,
&c->p.g.hc_mf, &in_cur_base,
&in_cur_base, in_next + 1,
in_next + 1, in_end,
in_end, length - 1,
length - 1, next_hashes);
next_hashes); in_next += length;
} else { } else {
/* No match found. */ /* No match found. */
deflate_choose_literal(c, *in_next, seq); 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) { if (cur_len >= nice_len) {
deflate_choose_match(c, cur_len, cur_offset, deflate_choose_match(c, cur_len, cur_offset,
&seq); &seq);
in_next = hc_matchfinder_skip_positions( hc_matchfinder_skip_positions(&c->p.g.hc_mf,
&c->p.g.hc_mf, &in_cur_base,
&in_cur_base, in_next,
in_next, in_end,
in_end, cur_len - 1,
cur_len - 1, next_hashes);
next_hashes); in_next += cur_len - 1;
continue; continue;
} }
@ -2384,14 +2384,16 @@ deflate_compress_lazy_generic(struct libdeflate_compressor * restrict c,
*/ */
deflate_choose_match(c, cur_len, cur_offset, deflate_choose_match(c, cur_len, cur_offset,
&seq); &seq);
if (cur_len > 3) if (cur_len > 3) {
in_next = hc_matchfinder_skip_positions( hc_matchfinder_skip_positions(
&c->p.g.hc_mf, &c->p.g.hc_mf,
&in_cur_base, &in_cur_base,
in_next, in_next,
in_end, in_end,
cur_len - 3, cur_len - 3,
next_hashes); next_hashes);
in_next += cur_len - 3;
}
} else { /* !lazy2 */ } else { /* !lazy2 */
/* /*
* No better match at the next position. Output * 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, deflate_choose_match(c, cur_len, cur_offset,
&seq); &seq);
in_next = hc_matchfinder_skip_positions( hc_matchfinder_skip_positions(&c->p.g.hc_mf,
&c->p.g.hc_mf, &in_cur_base,
&in_cur_base, in_next,
in_next, in_end,
in_end, cur_len - 2,
cur_len - 2, next_hashes);
next_hashes); in_next += cur_len - 2;
} }
/* Check if it's time to output another block. */ /* Check if it's time to output another block. */
} while (in_next < in_max_block_end && } while (in_next < in_max_block_end &&

View File

@ -357,10 +357,8 @@ out:
* The precomputed hash codes for the sequence beginning at @in_next. * The precomputed hash codes for the sequence beginning at @in_next.
* These will be used and then updated with the precomputed hashcodes for * These will be used and then updated with the precomputed hashcodes for
* the sequence beginning at @in_next + @count. * 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, hc_matchfinder_skip_positions(struct hc_matchfinder * const restrict mf,
const u8 ** const restrict in_base_p, const u8 ** const restrict in_base_p,
const u8 *in_next, const u8 *in_next,
@ -374,7 +372,7 @@ hc_matchfinder_skip_positions(struct hc_matchfinder * const restrict mf,
u32 remaining = count; u32 remaining = count;
if (unlikely(count + 5 > in_end - in_next)) if (unlikely(count + 5 > in_end - in_next))
return &in_next[count]; return;
cur_pos = in_next - *in_base_p; cur_pos = in_next - *in_base_p;
hash3 = next_hashes[0]; hash3 = next_hashes[0];
@ -399,8 +397,6 @@ hc_matchfinder_skip_positions(struct hc_matchfinder * const restrict mf,
prefetchw(&mf->hash4_tab[hash4]); prefetchw(&mf->hash4_tab[hash4]);
next_hashes[0] = hash3; next_hashes[0] = hash3;
next_hashes[1] = hash4; next_hashes[1] = hash4;
return in_next;
} }
#endif /* LIB_HC_MATCHFINDER_H */ #endif /* LIB_HC_MATCHFINDER_H */