- if (likely(bytes_remaining >= 2)) {
- const u32 max_len = min(LZX_MAX_MATCH_LEN, bytes_remaining);
- const u16 str = *(const u16 *)strptr;
- for (unsigned i = 0; i < LZX_NUM_RECENT_OFFSETS; i++) {
- const u8 * const matchptr = strptr - queue->R[i];
-
- /* Check the first two bytes. If they match, then
- * extend the match to its full length. */
- if (*(const u16 *)matchptr == str) {
- const u32 len = lz_extend(strptr, matchptr,
- 2, max_len);
- if (len > best_len) {
- best_len = len;
- *slot_ret = i;
- }
- }
- }
- }
- return best_len;
+ return lz_repsearch(strptr, bytes_remaining, LZX_MAX_MATCH_LEN,
+ queue->R, LZX_NUM_RECENT_OFFSETS, slot_ret);