summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2018-05-02 17:33:12 (GMT)
committerYann Collet <cyan@fb.com>2018-05-02 17:33:12 (GMT)
commit1a191b3f8d26b50a7c1d41590b529ec308d768cd (patch)
tree32953da64fa1ee687cafa564088153b4ed6b6e44
parent0114b63b40dd58267d8680605cd3000264ce2820 (diff)
downloadlz4-1a191b3f8d26b50a7c1d41590b529ec308d768cd.zip
lz4-1a191b3f8d26b50a7c1d41590b529ec308d768cd.tar.gz
lz4-1a191b3f8d26b50a7c1d41590b529ec308d768cd.tar.bz2
simplify shortcut
-rw-r--r--lib/lz4.c77
1 files changed, 22 insertions, 55 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index c6f0426..b46910f 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -1429,62 +1429,29 @@ LZ4_FORCE_INLINE int LZ4_decompress_generic(
*/
if ((endOnInput ? length != RUN_MASK : length <= 8) &&
/* strictly "less than" on input, to re-enter the loop with at least one byte */
- likely((endOnInput ? ip < shortiend : 1) && (op <= shortoend)))
+ likely((endOnInput ? ip < shortiend : 1) & (op <= shortoend)))
{
- /* Can we copy the literals with a single memcpy invocation? Sometimes we can't
- * copy 16 bytes, because they can clobber the dictionary in the ring buffer. */
- if (!endOnInput /* only 8 bytes */ || /* nothing to clobber */ dict != usingExtDict) {
- /* Copy the literals. */
- memcpy(op, ip, endOnInput ? 16 : 8);
- op += length; ip += length;
-
- /* The second stage: prepare for match copying, decode full info.
- * It if doesn't work out, the info won't be wasted. */
- length = token & ML_MASK; /* match length */
- offset = LZ4_readLE16(ip); ip += 2;
- match = op - offset;
-
- /* Do not deal with overlapping matches. */
- if ((length != 15) && (offset >= 8) &&
- (dict==withPrefix64k || match >= lowPrefix))
- {
- /* Copy the match. */
- memcpy(op + 0, match + 0, 8);
- memcpy(op + 8, match + 8, 8);
- memcpy(op +16, match +16, 2);
- op += length + MINMATCH;
- /* Both stages worked, load the next token. */
- continue;
- }
- } else {
- /* Save the literal length, can't copy 16 bytes just yet. */
- size_t ll = length;
-
- /* Prepare for the second satge. */
- length = token & ML_MASK;
- offset = LZ4_readLE16(ip+ll);
- match = op + ll - offset;
-
- if ((length != 15) && (offset >= 8) &&
- (dict==withPrefix64k || match >= lowPrefix))
- {
- /* Copy the literals. */
- memcpy(op, ip, 16);
- op += ll; ip += ll + 2;
- /* Copy the match. */
- memcpy(op + 0, match + 0, 8);
- memcpy(op + 8, match + 8, 8);
- memcpy(op +16, match +16, 2);
- op += length + MINMATCH;
- /* Both stages worked, load the next token. */
- continue;
- }
-
- /* So we took the literlas, but the second stage didn't work. */
- memcpy(op, ip, 8);
- if (ll > 8)
- memcpy(op + 8, ip + 8, 8);
- op += ll; ip += ll + 2;
+ /* Copy the literals. */
+ memcpy(op, ip, endOnInput ? 16 : 8);
+ op += length; ip += length;
+
+ /* The second stage: prepare for match copying, decode full info.
+ * If it doesn't work out, the info won't be wasted. */
+ length = token & ML_MASK; /* match length */
+ offset = LZ4_readLE16(ip); ip += 2;
+ match = op - offset;
+
+ /* Do not deal with overlapping matches. */
+ if ((length != 15) && (offset >= 8) &&
+ (dict==withPrefix64k || match >= lowPrefix))
+ {
+ /* Copy the match. */
+ memcpy(op + 0, match + 0, 8);
+ memcpy(op + 8, match + 8, 8);
+ memcpy(op +16, match +16, 2);
+ op += length + MINMATCH;
+ /* Both stages worked, load the next token. */
+ continue;
}
/* The second stage didn't work out, but the info is ready.