diff options
author | Yann Collet <Cyan4973@users.noreply.github.com> | 2017-11-07 20:09:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-07 20:09:32 (GMT) |
commit | e6365b1854eddb9772693db50b07e9057d0fe4f6 (patch) | |
tree | ef5afd10312bc1093cfed666bf798a15a0a94f36 /lib/lz4.c | |
parent | ce8393e8d7c55e69c73ccff0c37c32f5b0e86b6c (diff) | |
parent | 9221419c6fad7d714369cb549b123825fd041d49 (diff) | |
download | lz4-e6365b1854eddb9772693db50b07e9057d0fe4f6.zip lz4-e6365b1854eddb9772693db50b07e9057d0fe4f6.tar.gz lz4-e6365b1854eddb9772693db50b07e9057d0fe4f6.tar.bz2 |
Merge pull request #418 from lz4/fasterCount
faster LZ4_count()
Diffstat (limited to 'lib/lz4.c')
-rw-r--r-- | lib/lz4.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -403,11 +403,20 @@ static unsigned LZ4_NbCommonBytes (REGISTER reg_t val) } #define STEPSIZE sizeof(reg_t) -static unsigned LZ4_count(const BYTE* pIn, const BYTE* pMatch, const BYTE* pInLimit) +LZ4_FORCE_INLINE +unsigned LZ4_count(const BYTE* pIn, const BYTE* pMatch, const BYTE* pInLimit) { 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); |