diff options
author | Dave Watson <davejwatson@fb.com> | 2019-01-26 00:01:09 (GMT) |
---|---|---|
committer | Dave Watson <davejwatson@fb.com> | 2019-02-08 21:57:23 (GMT) |
commit | 28b824921d94c8263cb51dfdee0a149490009f8f (patch) | |
tree | 972f70b73e0dd8b96dbfe75564f391095c66c154 /lib/lz4.c | |
parent | 232f1e261fce421542e0cf7549f25e3064006bf0 (diff) | |
download | lz4-28b824921d94c8263cb51dfdee0a149490009f8f.zip lz4-28b824921d94c8263cb51dfdee0a149490009f8f.tar.gz lz4-28b824921d94c8263cb51dfdee0a149490009f8f.tar.bz2 |
decompress_generic: re-add fastpath
This is the remaineder of the original 'shortcut'. If true, we can avoid
the loop in LZ4_wildCopy, and directly copy instead.
Diffstat (limited to 'lib/lz4.c')
-rw-r--r-- | lib/lz4.c | 23 |
1 files changed, 19 insertions, 4 deletions
@@ -1592,11 +1592,26 @@ LZ4_decompress_generic( length += read_variable_length(&ip, iend - LASTLITERALS + 1, endOnInput, 0, &error); if (error != ok) goto _output_error; if ((safeDecode) && unlikely((uptrval)(op)+length<(uptrval)op)) goto _output_error; /* overflow detection */ - } - length += MINMATCH; + length += MINMATCH; + if (op + length >= oend - FASTLOOP_SAFE_DISTANCE) { + goto safe_match_copy; + } + } else { + length += MINMATCH; + if (op + length >= oend - FASTLOOP_SAFE_DISTANCE) { + goto safe_match_copy; + } - if (op + length >= oend - FASTLOOP_SAFE_DISTANCE) { - goto safe_match_copy; + /* Fastpath check: Avoids a branch in LZ4_wildCopy16 if true */ + if (!(dict == usingExtDict) || (match >= lowPrefix)) { + if (offset >= 8) { + memcpy(op, match, 8); + memcpy(op+8, match+8, 8); + memcpy(op+16, match+16, 2); + op += length; + continue; + } + } } /* match starting within external dictionary */ |