diff options
author | Yann Collet <cyan@fb.com> | 2017-11-06 23:42:50 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2017-11-06 23:42:50 (GMT) |
commit | d51f0466289d9a021291e736b463cf8de7bd60bd (patch) | |
tree | 2544ff61b33faa9be17babc0bbd7eaa55c703018 | |
parent | ce8393e8d7c55e69c73ccff0c37c32f5b0e86b6c (diff) | |
download | lz4-d51f0466289d9a021291e736b463cf8de7bd60bd.zip lz4-d51f0466289d9a021291e736b463cf8de7bd60bd.tar.gz lz4-d51f0466289d9a021291e736b463cf8de7bd60bd.tar.bz2 |
2-stages LZ4_count
separate first branch from the rest of the compare loop
to get dedicated prediction.
measured a 3-4% compression speed improvement.
-rw-r--r-- | lib/lz4.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -407,7 +407,15 @@ static unsigned LZ4_count(const BYTE* pIn, const BYTE* pMatch, const BYTE* pInLi { const BYTE* const pStart = pIn; - while (likely(pIn<pInLimit-(STEPSIZE-1))) { + if (likely(pIn < pInLimit-(STEPSIZE-1))) { + reg_t const diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn); + if (!diff) { + pIn+=STEPSIZE; pMatch+=STEPSIZE; + } else { + return LZ4_NbCommonBytes(diff); + } } + + while (likely(pIn < pInLimit-(STEPSIZE-1))) { reg_t const diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn); if (!diff) { pIn+=STEPSIZE; pMatch+=STEPSIZE; continue; } pIn += LZ4_NbCommonBytes(diff); |