summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2017-10-31 21:20:25 (GMT)
committerYann Collet <cyan@fb.com>2017-10-31 21:20:25 (GMT)
commit9378f76e4186e7b4f33a79451b22afd5b6344c8d (patch)
tree4173e969713d804a2297703cf92249e1cdf66238 /lib
parentace334a4c94927d97933888b343a2f435bbbc7fa (diff)
downloadlz4-9378f76e4186e7b4f33a79451b22afd5b6344c8d.zip
lz4-9378f76e4186e7b4f33a79451b22afd5b6344c8d.tar.gz
lz4-9378f76e4186e7b4f33a79451b22afd5b6344c8d.tar.bz2
extended shortcut match length to 18
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 34d8c40..1504790 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -1181,18 +1181,19 @@ LZ4_FORCE_INLINE int LZ4_decompress_generic(
unsigned const token = *ip++;
/* shortcut for common case :
- * in most circumstances, we expect to decode small matches (<= 16 bytes) separated by few literals (<= 14 bytes).
+ * in most circumstances, we expect to decode small matches (<= 18 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<<ML_BITS)) & ((token & ML_MASK) <= 12)) ) {
+ if (((ip + 14 /*maxLL*/ + 2 /*offset*/ <= iend)
+ & (op + 14 /*maxLL*/ + 18 /*maxML*/ <= oend))
+ & ((token < (15<<ML_BITS)) & ((token & ML_MASK) != 15)) ) {
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) /* do not deal with overlapping matches */ & (matchPtr >= lowPrefix)) {
+ if ((off >= 18) /* do not deal with overlapping matches */ & (matchPtr >= lowPrefix)) {
size_t const ml = (token & ML_MASK) + MINMATCH;
memcpy(op, ip, 16); op += ll; ip += ll + 2 /*offset*/;
- memcpy(op, matchPtr, 16); op += ml;
+ memcpy(op, matchPtr, 18); op += ml;
continue;
}
}