diff options
author | Yann Collet <cyan@fb.com> | 2020-09-28 04:04:40 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2020-09-28 04:04:40 (GMT) |
commit | e7fe105ac6ed02019d34731d2ba3aceb11b51bb1 (patch) | |
tree | aead7ea0a02aed25e39e30ed3c525cd3ee6cfa30 /lib/lz4.c | |
parent | 20856da7c571cc1ee55965a342527f8263dc356d (diff) | |
download | lz4-e7fe105ac6ed02019d34731d2ba3aceb11b51bb1.zip lz4-e7fe105ac6ed02019d34731d2ba3aceb11b51bb1.tar.gz lz4-e7fe105ac6ed02019d34731d2ba3aceb11b51bb1.tar.bz2 |
fix efficiency of LZ4_compress_HC_destSize()
LZ4_compress_HC_destSize() had a tendency
to discard its last match when this match overflowed specified dstBuffer limit.
The impact is generally moderate,
but occasionally huge,
typically when this last match is very large
(such as compressing a bunch of zeroes).
Issue #784 fixed for both Chain and Opt implementations.
Added a unit test suggested by @remittor checking this topic.
Diffstat (limited to 'lib/lz4.c')
-rw-r--r-- | lib/lz4.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -247,6 +247,7 @@ static const int LZ4_minLength = (MFLIMIT+1); /*-************************************ * Types **************************************/ +#include <limits.h> #if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) # include <stdint.h> typedef uint8_t BYTE; @@ -256,7 +257,6 @@ static const int LZ4_minLength = (MFLIMIT+1); typedef uint64_t U64; typedef uintptr_t uptrval; #else -# include <limits.h> # if UINT_MAX != 4294967295UL # error "LZ4 code (when not C++ or C99) assumes that sizeof(int) == 4" # endif @@ -1192,6 +1192,7 @@ _last_literals: return 0; /* cannot compress within `dst` budget. Stored indexes in hash table are nonetheless fine */ } } + DEBUGLOG(6, "Final literal run : %i literals", (int)lastRun); if (lastRun >= RUN_MASK) { size_t accumulator = lastRun - RUN_MASK; *op++ = RUN_MASK << ML_BITS; |