*
* 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.
*/
const u32 start_len, const u32 max_len)
{
u32 len = start_len;
+ machine_word_t v_word;
if (UNALIGNED_ACCESS_IS_FAST) {
- machine_word_t v_word;
-
if (likely(max_len - len >= 4 * WORDSIZE)) {
#define COMPARE_WORD_STEP \
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 */