X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Flzx-compress.c;h=cf5ea48ef834e4511d29dcf9b91c7cc637bd3de8;hb=2915014b741493083571954e10c8add9dc09a522;hp=9851faa42bd30a5d758aaa954c1480b4f6f0011c;hpb=caee331995aa6e25cece83969e4a6e2f3a85f862;p=wimlib diff --git a/src/lzx-compress.c b/src/lzx-compress.c index 9851faa4..cf5ea48e 100644 --- a/src/lzx-compress.c +++ b/src/lzx-compress.c @@ -198,8 +198,8 @@ #include "wimlib/compress_common.h" #include "wimlib/endianness.h" #include "wimlib/error.h" -#include "wimlib/lz_extend.h" #include "wimlib/lz_mf.h" +#include "wimlib/lz_repsearch.h" #include "wimlib/lzx.h" #include "wimlib/util.h" #include @@ -1501,28 +1501,9 @@ static inline u32 lzx_repsearch(const u8 * const strptr, const u32 bytes_remaining, const struct lzx_lru_queue *queue, unsigned *slot_ret) { - u32 best_len = 0; - BUILD_BUG_ON(LZX_MIN_MATCH_LEN != 2); - 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); } /*