summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <Cyan4973@users.noreply.github.com>2018-02-13 00:56:45 (GMT)
committerGitHub <noreply@github.com>2018-02-13 00:56:45 (GMT)
commit3d3d5af4e13baab469cec4119c926e52cc3e497d (patch)
treeac81602c1317a5760ad098b4e172f3576ae73b22
parentf76ee4e267e567bbce611aecd91f41b5de3b44d5 (diff)
parent219abab74bf8914d3f8761db5b398103cbbd77d7 (diff)
downloadlz4-3d3d5af4e13baab469cec4119c926e52cc3e497d.zip
lz4-3d3d5af4e13baab469cec4119c926e52cc3e497d.tar.gz
lz4-3d3d5af4e13baab469cec4119c926e52cc3e497d.tar.bz2
Merge pull request #470 from lz4/fasterDec
Faster decoding speed
-rw-r--r--lib/lz4.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 7bf8677..5d4bb21 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -270,11 +270,6 @@ static void LZ4_writeLE16(void* memPtr, U16 value)
}
}
-static void LZ4_copy8(void* dst, const void* src)
-{
- memcpy(dst,src,8);
-}
-
/* customized variant of memcpy, which can overwrite up to 8 bytes beyond dstEnd */
LZ4_FORCE_O2_INLINE_GCC_PPC64LE
void LZ4_wildCopy(void* dstPtr, const void* srcPtr, void* dstEnd)
@@ -283,7 +278,7 @@ void LZ4_wildCopy(void* dstPtr, const void* srcPtr, void* dstEnd)
const BYTE* s = (const BYTE*)srcPtr;
BYTE* const e = (BYTE*)dstEnd;
- do { LZ4_copy8(d,s); d+=8; s+=8; } while (d<e);
+ do { memcpy(d,s,8); d+=8; s+=8; } while (d<e);
}
@@ -1220,10 +1215,13 @@ LZ4_FORCE_INLINE int LZ4_decompress_generic(
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 >= 18) /* do not deal with overlapping matches */ & (matchPtr >= lowPrefix)) {
+ if ((off >= 8) /* 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, 18); op += ml;
+ memcpy(op + 0, matchPtr + 0, 8);
+ memcpy(op + 8, matchPtr + 8, 8);
+ memcpy(op +16, matchPtr +16, 2);
+ op += ml;
continue;
}
}
@@ -1313,7 +1311,7 @@ LZ4_FORCE_INLINE int LZ4_decompress_generic(
match += inc32table[offset];
memcpy(op+4, match, 4);
match -= dec64table[offset];
- } else { LZ4_copy8(op, match); match+=8; }
+ } else { memcpy(op, match, 8); match+=8; }
op += 8;
if (unlikely(cpy>oend-12)) {
@@ -1326,7 +1324,7 @@ LZ4_FORCE_INLINE int LZ4_decompress_generic(
}
while (op<cpy) *op++ = *match++;
} else {
- LZ4_copy8(op, match);
+ memcpy(op, match, 8);
if (length>16) LZ4_wildCopy(op+8, match+8, cpy);
}
op = cpy; /* correction */