X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=include%2Fwimlib%2Flz_extend.h;h=bd00183b973d980b5eab3f1aa2acf4b263e18569;hp=d47e0976d5836ff0214dcfc6563bec63911a559d;hb=f50557a7095444c554a066b3837c2999ecd1be31;hpb=bffa1310d24ef2e9330dd5ea3b5aef1ff0ca380b diff --git a/include/wimlib/lz_extend.h b/include/wimlib/lz_extend.h index d47e0976..bd00183b 100644 --- a/include/wimlib/lz_extend.h +++ b/include/wimlib/lz_extend.h @@ -3,6 +3,9 @@ * * Fast match extension for Lempel-Ziv matchfinding. * + * Author: Eric Biggers + * Year: 2014, 2015 + * * The author dedicates this file to the public domain. * You can do whatever you want with this file. */ @@ -20,10 +23,9 @@ lz_extend(const u8 * const strptr, const u8 * const matchptr, const u32 start_len, const u32 max_len) { u32 len = start_len; + machine_word_t v_word; - if (UNALIGNED_ACCESS_IS_FAST && CPU_IS_LITTLE_ENDIAN) { - - machine_word_t v_word; + if (UNALIGNED_ACCESS_IS_FAST) { if (likely(max_len - len >= 4 * WORDSIZE)) { @@ -48,18 +50,18 @@ lz_extend(const u8 * const strptr, const u8 * const matchptr, goto word_differs; len += WORDSIZE; } + } - while (len < max_len && matchptr[len] == strptr[len]) - len++; - return len; + while (len < max_len && matchptr[len] == strptr[len]) + len++; + return len; - word_differs: - return len + (ffsw(v_word) >> 3); - } else { - while (len < max_len && matchptr[len] == strptr[len]) - len++; - return len; - } +word_differs: + if (CPU_IS_LITTLE_ENDIAN) + len += (ffsw(v_word) >> 3); + else + len += (flsw(v_word) >> 3); + return len; } #endif /* _WIMLIB_LZ_EXTEND_H */