- return num_matches;
-}
-
-static u32
-lz_hc_get_matches(struct lz_mf *_mf, struct lz_match matches[])
-{
- struct lz_hc *mf = (struct lz_hc *)_mf;
- const u32 bytes_remaining = lz_mf_get_bytes_remaining(&mf->base);
- u32 hash;
- u32 cur_match;
- u32 num_matches = 0;
-
- if (bytes_remaining <= LZ_HC_HASH_BYTES)
- goto out;
-
- hash = mf->next_hash;
- mf->next_hash = lz_hc_hash(lz_mf_get_window_ptr(&mf->base) + 1);
- prefetch(&mf->hash_tab[mf->next_hash]);
- cur_match = mf->hash_tab[hash];
- mf->hash_tab[hash] = mf->base.cur_window_pos;
- mf->prev_tab[mf->base.cur_window_pos] = cur_match;
-
- num_matches = do_search(mf->base.cur_window,
- mf->base.cur_window_pos,
- mf->prev_tab,
- cur_match,
- mf->base.params.min_match_len,
- min(bytes_remaining, mf->base.params.nice_match_len),
- mf->base.params.max_search_depth,
- matches);
-
- /* If the longest match is @nice_match_len in length, it may have been
- * truncated. Try extending it up to the maximum match length. */
- if (num_matches != 0 &&
- matches[num_matches - 1].len == mf->base.params.nice_match_len)
- {
- const u8 * const strptr = lz_mf_get_window_ptr(&mf->base);
- const u8 * const matchptr = strptr - matches[num_matches - 1].offset;
- const u32 len_limit = min(bytes_remaining, mf->base.params.max_match_len);
- u32 len;
-
- len = matches[num_matches - 1].len;
- while (len < len_limit && strptr[len] == matchptr[len])
- len++;
- matches[num_matches - 1].len = len;
- }