mirror of
https://github.com/cuberite/libdeflate.git
synced 2025-08-03 09:46:04 -04:00
matchfinder: rename skip_positions() to skip_bytes()
This is a bit shorter, and perhaps clearer.
This commit is contained in:
parent
320c306db3
commit
8012927541
@ -132,7 +132,7 @@ bt_right_child(struct bt_matchfinder *mf, s32 node)
|
||||
}
|
||||
|
||||
/* The minimum permissible value of 'max_len' for bt_matchfinder_get_matches()
|
||||
* and bt_matchfinder_skip_position(). There must be sufficiently many bytes
|
||||
* and bt_matchfinder_skip_byte(). There must be sufficiently many bytes
|
||||
* remaining to load a 32-bit integer from the *next* position. */
|
||||
#define BT_MATCHFINDER_REQUIRED_NBYTES 5
|
||||
|
||||
@ -334,12 +334,12 @@ bt_matchfinder_get_matches(struct bt_matchfinder *mf,
|
||||
* must do hashing and tree re-rooting.
|
||||
*/
|
||||
static forceinline void
|
||||
bt_matchfinder_skip_position(struct bt_matchfinder *mf,
|
||||
const u8 *in_base,
|
||||
ptrdiff_t cur_pos,
|
||||
u32 nice_len,
|
||||
u32 max_search_depth,
|
||||
u32 next_hashes[2])
|
||||
bt_matchfinder_skip_byte(struct bt_matchfinder *mf,
|
||||
const u8 *in_base,
|
||||
ptrdiff_t cur_pos,
|
||||
u32 nice_len,
|
||||
u32 max_search_depth,
|
||||
u32 next_hashes[2])
|
||||
{
|
||||
u32 best_len;
|
||||
bt_matchfinder_advance_one_byte(mf,
|
||||
|
@ -2182,12 +2182,12 @@ deflate_compress_greedy(struct libdeflate_compressor * restrict c,
|
||||
/* Match found. */
|
||||
deflate_choose_match(c, length, offset, &seq);
|
||||
observe_match(&c->split_stats, length);
|
||||
hc_matchfinder_skip_positions(&c->p.g.hc_mf,
|
||||
&in_cur_base,
|
||||
in_next + 1,
|
||||
in_end,
|
||||
length - 1,
|
||||
next_hashes);
|
||||
hc_matchfinder_skip_bytes(&c->p.g.hc_mf,
|
||||
&in_cur_base,
|
||||
in_next + 1,
|
||||
in_end,
|
||||
length - 1,
|
||||
next_hashes);
|
||||
in_next += length;
|
||||
} else {
|
||||
/* No match found. */
|
||||
@ -2295,12 +2295,12 @@ deflate_compress_lazy_generic(struct libdeflate_compressor * restrict c,
|
||||
if (cur_len >= nice_len) {
|
||||
deflate_choose_match(c, cur_len, cur_offset,
|
||||
&seq);
|
||||
hc_matchfinder_skip_positions(&c->p.g.hc_mf,
|
||||
&in_cur_base,
|
||||
in_next,
|
||||
in_end,
|
||||
cur_len - 1,
|
||||
next_hashes);
|
||||
hc_matchfinder_skip_bytes(&c->p.g.hc_mf,
|
||||
&in_cur_base,
|
||||
in_next,
|
||||
in_end,
|
||||
cur_len - 1,
|
||||
next_hashes);
|
||||
in_next += cur_len - 1;
|
||||
continue;
|
||||
}
|
||||
@ -2385,13 +2385,12 @@ deflate_compress_lazy_generic(struct libdeflate_compressor * restrict c,
|
||||
deflate_choose_match(c, cur_len, cur_offset,
|
||||
&seq);
|
||||
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);
|
||||
hc_matchfinder_skip_bytes(&c->p.g.hc_mf,
|
||||
&in_cur_base,
|
||||
in_next,
|
||||
in_end,
|
||||
cur_len - 3,
|
||||
next_hashes);
|
||||
in_next += cur_len - 3;
|
||||
}
|
||||
} else { /* !lazy2 */
|
||||
@ -2401,12 +2400,12 @@ deflate_compress_lazy_generic(struct libdeflate_compressor * restrict c,
|
||||
*/
|
||||
deflate_choose_match(c, cur_len, cur_offset,
|
||||
&seq);
|
||||
hc_matchfinder_skip_positions(&c->p.g.hc_mf,
|
||||
&in_cur_base,
|
||||
in_next,
|
||||
in_end,
|
||||
cur_len - 2,
|
||||
next_hashes);
|
||||
hc_matchfinder_skip_bytes(&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. */
|
||||
@ -3153,7 +3152,7 @@ deflate_compress_near_optimal(struct libdeflate_compressor * restrict c,
|
||||
remaining);
|
||||
if (max_len >=
|
||||
BT_MATCHFINDER_REQUIRED_NBYTES) {
|
||||
bt_matchfinder_skip_position(
|
||||
bt_matchfinder_skip_byte(
|
||||
&c->p.n.bt_mf,
|
||||
in_cur_base,
|
||||
in_next - in_cur_base,
|
||||
|
@ -73,7 +73,7 @@
|
||||
* chain for length 3+ matches, the algorithm just checks for one close length 3
|
||||
* match, then focuses on finding length 4+ matches.
|
||||
*
|
||||
* The longest_match() and skip_positions() functions are inlined into the
|
||||
* The longest_match() and skip_bytes() functions are inlined into the
|
||||
* compressors that use them. This isn't just about saving the overhead of a
|
||||
* function call. These functions are intended to be called from the inner
|
||||
* loops of compressors, where giving the compiler more control over register
|
||||
@ -359,12 +359,12 @@ out:
|
||||
* the sequence beginning at @in_next + @count.
|
||||
*/
|
||||
static forceinline void
|
||||
hc_matchfinder_skip_positions(struct hc_matchfinder * const restrict mf,
|
||||
const u8 ** const restrict in_base_p,
|
||||
const u8 *in_next,
|
||||
const u8 * const in_end,
|
||||
const u32 count,
|
||||
u32 * const restrict next_hashes)
|
||||
hc_matchfinder_skip_bytes(struct hc_matchfinder * const restrict mf,
|
||||
const u8 ** const restrict in_base_p,
|
||||
const u8 *in_next,
|
||||
const u8 * const in_end,
|
||||
const u32 count,
|
||||
u32 * const restrict next_hashes)
|
||||
{
|
||||
u32 cur_pos;
|
||||
u32 hash3, hash4;
|
||||
|
Loading…
x
Reference in New Issue
Block a user