summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPrzemyslaw Skibinski <inikep@gmail.com>2016-12-09 17:17:46 (GMT)
committerPrzemyslaw Skibinski <inikep@gmail.com>2016-12-09 17:17:46 (GMT)
commit4f050b68d817776e3c1fac6c449b5f2b2adfbcb9 (patch)
tree01d092019595311b4aa54f5a7a63dae0cb40a0ab /lib
parent838ed341f94aa68c0bce8ee181e33a87274d2202 (diff)
downloadlz4-4f050b68d817776e3c1fac6c449b5f2b2adfbcb9.zip
lz4-4f050b68d817776e3c1fac6c449b5f2b2adfbcb9.tar.gz
lz4-4f050b68d817776e3c1fac6c449b5f2b2adfbcb9.tar.bz2
tree update dependent from compression level
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4hc.c6
-rw-r--r--lib/lz4hc.h1
-rw-r--r--lib/lz4opt.h4
3 files changed, 7 insertions, 4 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c
index e1eadf7..44a1340 100644
--- a/lib/lz4hc.c
+++ b/lib/lz4hc.c
@@ -574,8 +574,10 @@ int LZ4_loadDictHC (LZ4_streamHC_t* LZ4_streamHCPtr, const char* dictionary, int
static void LZ4HC_setExternalDict(LZ4HC_CCtx_internal* ctxPtr, const BYTE* newBlock)
{
- if (ctxPtr->end >= ctxPtr->base + 4) LZ4HC_Insert (ctxPtr, ctxPtr->end-3); /* Referencing remaining dictionary content */
- LZ4HC_updateBinTree(ctxPtr, ctxPtr->end - MFLIMIT, ctxPtr->end - LASTLITERALS);
+ if (ctxPtr->compressionLevel >= LZ4HC_MIN_CLEVEL_OPT)
+ LZ4HC_updateBinTree(ctxPtr, ctxPtr->end - MFLIMIT, ctxPtr->end - LASTLITERALS);
+ else
+ if (ctxPtr->end >= ctxPtr->base + 4) LZ4HC_Insert (ctxPtr, ctxPtr->end-3); /* Referencing remaining dictionary content */
/* Only one memory segment for extDict, so any previous extDict is lost at this stage */
ctxPtr->lowLimit = ctxPtr->dictLimit;
diff --git a/lib/lz4hc.h b/lib/lz4hc.h
index a3736f8..7ce5958 100644
--- a/lib/lz4hc.h
+++ b/lib/lz4hc.h
@@ -46,6 +46,7 @@ extern "C" {
/* --- Useful constants --- */
#define LZ4HC_MIN_CLEVEL 3
#define LZ4HC_DEFAULT_CLEVEL 9
+#define LZ4HC_MIN_CLEVEL_OPT 11
#define LZ4HC_MAX_CLEVEL 12
diff --git a/lib/lz4opt.h b/lib/lz4opt.h
index 0844f8e..f487edf 100644
--- a/lib/lz4opt.h
+++ b/lib/lz4opt.h
@@ -36,7 +36,7 @@
#define LZ4_LOG_PARSER(fmt, ...) //printf(fmt, __VA_ARGS__)
#define LZ4_LOG_PRICE(fmt, ...) //printf(fmt, __VA_ARGS__)
#define LZ4_LOG_ENCODE(fmt, ...) //printf(fmt, __VA_ARGS__)
-#include <stdio.h>
+
#define LZ4_OPT_NUM (1<<12)
@@ -189,7 +189,7 @@ FORCE_INLINE int LZ4HC_BinTree_GetAllMatches (
if (ip < ctx->base + ctx->nextToUpdateBT) return 0; /* skipped area */
if (fullUpdate) LZ4HC_updateBinTree(ctx, ip, iHighLimit);
best_mlen = LZ4HC_BinTree_InsertAndGetAllMatches(ctx, ip, iHighLimit, best_mlen, matches, &mnum);
- ctx->nextToUpdateBT = (U32)(ip - ctx->base) + best_mlen;
+ ctx->nextToUpdateBT = (U32)(ip - ctx->base + best_mlen);
return mnum;
}