]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Fix `dmsBtLow` Test
authorW. Felix Handte <w@felixhandte.com>
Thu, 21 Jun 2018 19:24:08 +0000 (15:24 -0400)
committerW. Felix Handte <w@felixhandte.com>
Thu, 21 Jun 2018 19:53:40 +0000 (15:53 -0400)
lib/compress/zstd_lazy.c
lib/compress/zstd_opt.c

index 078d2036011a7a9db0e24768311107ce14b4f393..bfe944928202807aec1fbefc8a1493d1ecb8d097 100644 (file)
@@ -166,7 +166,7 @@ static size_t ZSTD_DUBT_findBetterDictMatch (
     U32*        const dictBt = dms->chainTable;
     U32         const btLog  = cParams->chainLog - 1;
     U32         const btMask = (1 << btLog) - 1;
-    U32         const btLow = (btMask >= dictHighLimit - dictLowLimit) ? 0 : dictHighLimit - btMask;
+    U32         const btLow = (btMask >= dictHighLimit - dictLowLimit) ? dictLowLimit : dictHighLimit - btMask;
 
     size_t commonLengthSmaller=0, commonLengthLarger=0;
     U32 matchEndIdx = current+8+1;
index 1d0ca9ca4bb569fffe089513f33b7e247cc7a632..3f7023f78c39d0139bb2a0b545ac5a312620f760 100644 (file)
@@ -532,7 +532,7 @@ U32 ZSTD_insertBtAndGetAllMatches (
     U32         const dmsHighLimit  = dictMode == ZSTD_dictMatchState ? (U32)(dmsEnd - dmsBase) : 0;
     U32         const dmsLowLimit   = dictMode == ZSTD_dictMatchState ? dms->window.lowLimit : 0;
     U32         const dmsIndexDelta = dictMode == ZSTD_dictMatchState ? windowLow - dmsHighLimit : 0;
-    U32         const dmsBtLow      = dictMode == ZSTD_dictMatchState || btMask >= dmsHighLimit ? 0 : dmsHighLimit - btMask;
+    U32         const dmsBtLow      = dictMode == ZSTD_dictMatchState && btMask < dmsHighLimit - dmsLowLimit ? dmsHighLimit - btMask : dmsLowLimit;
 
     size_t bestLength = lengthToBeat-1;
     DEBUGLOG(8, "ZSTD_insertBtAndGetAllMatches: current=%u", current);