tree update dependent from compression level
authorPrzemyslaw Skibinski <inikep@gmail.com>
Fri, 9 Dec 2016 17:17:46 +0000 (18:17 +0100)
committerPrzemyslaw Skibinski <inikep@gmail.com>
Fri, 9 Dec 2016 17:17:46 +0000 (18:17 +0100)
lib/lz4hc.c
lib/lz4hc.h
lib/lz4opt.h

index e1eadf7..44a1340 100644 (file)
@@ -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;
index a3736f8..7ce5958 100644 (file)
@@ -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
 
 
index 0844f8e..f487edf 100644 (file)
@@ -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;
 }