diff options
author | Yann Collet <yann.collet.73@gmail.com> | 2014-12-06 16:10:54 (GMT) |
---|---|---|
committer | Yann Collet <yann.collet.73@gmail.com> | 2014-12-06 16:10:54 (GMT) |
commit | c5decf7562a3b4065922ae6460b7785eb91366f8 (patch) | |
tree | cd2e5e71b7820515f409c0d226713d29213f8c23 /lib/lz4hc.c | |
parent | b827ecf72894156c1727482b145dc9e7a116dbc9 (diff) | |
download | lz4-c5decf7562a3b4065922ae6460b7785eb91366f8.zip lz4-c5decf7562a3b4065922ae6460b7785eb91366f8.tar.gz lz4-c5decf7562a3b4065922ae6460b7785eb91366f8.tar.bz2 |
minor refactoring
Diffstat (limited to 'lib/lz4hc.c')
-rw-r--r-- | lib/lz4hc.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c index 6690e81..45f1208 100644 --- a/lib/lz4hc.c +++ b/lib/lz4hc.c @@ -36,13 +36,12 @@ You can contact the author at : /************************************** Tuning Parameter **************************************/ -#define LZ4HC_DEFAULT_COMPRESSIONLEVEL 8 +static const int LZ4HC_compressionLevel_default = 8; /************************************** Includes **************************************/ -#include "lz4.h" #include "lz4hc.h" @@ -82,6 +81,8 @@ You can contact the author at : #define OPTIMAL_ML (int)((ML_MASK-1)+MINMATCH) +static const int g_maxCompressionLevel = 16; + /************************************** Local Types @@ -328,7 +329,6 @@ FORCE_INLINE int LZ4HC_encodeSequence ( } -#define MAX_COMPRESSION_LEVEL 16 static int LZ4HC_compress_generic ( void* ctxvoid, const char* source, @@ -361,9 +361,9 @@ static int LZ4HC_compress_generic ( /* init */ - if (compressionLevel > MAX_COMPRESSION_LEVEL) compressionLevel = MAX_COMPRESSION_LEVEL; - if (compressionLevel == 0) compressionLevel = LZ4HC_DEFAULT_COMPRESSIONLEVEL; - maxNbAttempts = 1 << compressionLevel; + if (compressionLevel > g_maxCompressionLevel) compressionLevel = g_maxCompressionLevel; + if (compressionLevel < 1) compressionLevel = LZ4HC_compressionLevel_default; + maxNbAttempts = 1 << (compressionLevel-1); ctx->end += inputSize; ip++; |