bt_matchfinder: remove best_len_ret parameter

It doesn't seem worthwhile to have bt_matchfinder_get_matches() return
the best_len separately anymore, especially since it doesn't work as
expected due to it not handling length 3 matches.
This commit is contained in:
Eric Biggers 2022-01-04 21:25:56 -08:00
parent 3675136c39
commit ea536bcce2
2 changed files with 2 additions and 15 deletions

View File

@ -146,7 +146,6 @@ bt_matchfinder_advance_one_byte(struct bt_matchfinder * const restrict mf,
const u32 nice_len, const u32 nice_len,
const u32 max_search_depth, const u32 max_search_depth,
u32 * const restrict next_hashes, u32 * const restrict next_hashes,
u32 * const restrict best_len_ret,
struct lz_match * restrict lz_matchptr, struct lz_match * restrict lz_matchptr,
const bool record_matches) const bool record_matches)
{ {
@ -212,7 +211,6 @@ bt_matchfinder_advance_one_byte(struct bt_matchfinder * const restrict mf,
if (cur_node <= cutoff) { if (cur_node <= cutoff) {
*pending_lt_ptr = MATCHFINDER_INITVAL; *pending_lt_ptr = MATCHFINDER_INITVAL;
*pending_gt_ptr = MATCHFINDER_INITVAL; *pending_gt_ptr = MATCHFINDER_INITVAL;
*best_len_ret = best_len;
return lz_matchptr; return lz_matchptr;
} }
@ -235,7 +233,6 @@ bt_matchfinder_advance_one_byte(struct bt_matchfinder * const restrict mf,
if (len >= nice_len) { if (len >= nice_len) {
*pending_lt_ptr = *bt_left_child(mf, cur_node); *pending_lt_ptr = *bt_left_child(mf, cur_node);
*pending_gt_ptr = *bt_right_child(mf, cur_node); *pending_gt_ptr = *bt_right_child(mf, cur_node);
*best_len_ret = best_len;
return lz_matchptr; return lz_matchptr;
} }
} }
@ -260,7 +257,6 @@ bt_matchfinder_advance_one_byte(struct bt_matchfinder * const restrict mf,
if (cur_node <= cutoff || !--depth_remaining) { if (cur_node <= cutoff || !--depth_remaining) {
*pending_lt_ptr = MATCHFINDER_INITVAL; *pending_lt_ptr = MATCHFINDER_INITVAL;
*pending_gt_ptr = MATCHFINDER_INITVAL; *pending_gt_ptr = MATCHFINDER_INITVAL;
*best_len_ret = best_len;
return lz_matchptr; return lz_matchptr;
} }
} }
@ -289,12 +285,6 @@ bt_matchfinder_advance_one_byte(struct bt_matchfinder * const restrict mf,
* 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 + 1. * the sequence beginning at @in_next + 1.
* @best_len_ret
* If a match of length >= 4 was found, then the length of the longest such
* match is written here; otherwise 3 is written here. (Note: this is
* redundant with the 'struct lz_match' array, but this is easier for the
* compiler to optimize when inlined and the caller immediately does a
* check against 'best_len'.)
* @lz_matchptr * @lz_matchptr
* An array in which this function will record the matches. The recorded * An array in which this function will record the matches. The recorded
* matches will be sorted by strictly increasing length and (non-strictly) * matches will be sorted by strictly increasing length and (non-strictly)
@ -312,7 +302,6 @@ bt_matchfinder_get_matches(struct bt_matchfinder *mf,
u32 nice_len, u32 nice_len,
u32 max_search_depth, u32 max_search_depth,
u32 next_hashes[2], u32 next_hashes[2],
u32 *best_len_ret,
struct lz_match *lz_matchptr) struct lz_match *lz_matchptr)
{ {
return bt_matchfinder_advance_one_byte(mf, return bt_matchfinder_advance_one_byte(mf,
@ -322,7 +311,6 @@ bt_matchfinder_get_matches(struct bt_matchfinder *mf,
nice_len, nice_len,
max_search_depth, max_search_depth,
next_hashes, next_hashes,
best_len_ret,
lz_matchptr, lz_matchptr,
true); true);
} }
@ -341,7 +329,6 @@ bt_matchfinder_skip_byte(struct bt_matchfinder *mf,
u32 max_search_depth, u32 max_search_depth,
u32 next_hashes[2]) u32 next_hashes[2])
{ {
u32 best_len;
bt_matchfinder_advance_one_byte(mf, bt_matchfinder_advance_one_byte(mf,
in_base, in_base,
cur_pos, cur_pos,
@ -349,7 +336,6 @@ bt_matchfinder_skip_byte(struct bt_matchfinder *mf,
nice_len, nice_len,
max_search_depth, max_search_depth,
next_hashes, next_hashes,
&best_len,
NULL, NULL,
false); false);
} }

View File

@ -3415,8 +3415,9 @@ deflate_compress_near_optimal(struct libdeflate_compressor * restrict c,
nice_len, nice_len,
c->max_search_depth, c->max_search_depth,
next_hashes, next_hashes,
&best_len,
matches); matches);
if (cache_ptr > matches)
best_len = cache_ptr[-1].length;
} }
c->freqs.litlen[*in_next]++; c->freqs.litlen[*in_next]++;
if (in_next >= next_observation) { if (in_next >= next_observation) {