diff options
author | Yann Collet <cyan@fb.com> | 2017-10-31 18:49:57 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2017-10-31 18:49:57 (GMT) |
commit | 3f173052aef1d0f1503bd986cc871e59ef56cadd (patch) | |
tree | df6216253b408558191e05f114e1762ccf86400e | |
parent | e0914ff70c4a8b94d900deeea44c7cd1e9ac4a07 (diff) | |
download | lz4-3f173052aef1d0f1503bd986cc871e59ef56cadd.zip lz4-3f173052aef1d0f1503bd986cc871e59ef56cadd.tar.gz lz4-3f173052aef1d0f1503bd986cc871e59ef56cadd.tar.bz2 |
added comments, as suggested by @terrelln
-rw-r--r-- | lib/lz4.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -1180,15 +1180,16 @@ LZ4_FORCE_INLINE int LZ4_decompress_generic( unsigned const token = *ip++; - /* shortcut for common case */ - /* this shortcut was tested on x86 and x64, where it improves decoding speed. + /* shortcut for common case : + * in most circumstances, we expect to decode small matches (<= 16 bytes) separated by few literals (<= 14 bytes). + * this shortcut was tested on x86 and x64, where it improves decoding speed. * it has not yet been benchmarked on ARM, Power, mips, etc. */ if (((ip + 14 + 2 <= iend) & (op + 14 + 16 <= oend)) - & ((token < 15*16) & ((token & 0xF) <= 12)) ) { + & ((token < (15<<ML_BITS)) & ((token & 0xF) <= 12)) ) { size_t const ll = token >> ML_BITS; size_t const off = LZ4_readLE16(ip+ll); const BYTE* const matchPtr = op + ll - off; /* pointer underflow risk ? */ - if ((off >= 16) & (matchPtr >= lowPrefix)) { + if ((off >= 16) /* do not deal with overlapping matches */ & (matchPtr >= lowPrefix)) { size_t const ml = (token & 0xF) + MINMATCH; memcpy(op, ip, 16); op += ll; ip += ll + 2 /*offset*/; memcpy(op, matchPtr, 16); op += ml; |