From: Yann Collet Date: Tue, 31 Oct 2017 18:49:57 +0000 (-0700) Subject: added comments, as suggested by @terrelln X-Git-Tag: upstream/1.9.3~11^2~29^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3f173052aef1d0f1503bd986cc871e59ef56cadd;p=platform%2Fupstream%2Flz4.git added comments, as suggested by @terrelln --- diff --git a/lib/lz4.c b/lib/lz4.c index 10f8d55..b036d98 100644 --- a/lib/lz4.c +++ b/lib/lz4.c @@ -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; 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;