From: Yann Collet Date: Fri, 2 Aug 2019 12:21:39 +0000 (+0200) Subject: fixed strategies greedy, lazy & lazy2 X-Git-Tag: v1.4.3^2~5^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5cf1b24acac81310ac4c6da63b7fc95a2cf9fbe4;p=thirdparty%2Fzstd.git fixed strategies greedy, lazy & lazy2 restore dictionary compression ratio --- diff --git a/lib/compress/zstd_lazy.c b/lib/compress/zstd_lazy.c index 9d47366fd..c6f45c307 100644 --- a/lib/compress/zstd_lazy.c +++ b/lib/compress/zstd_lazy.c @@ -497,8 +497,10 @@ size_t ZSTD_HcFindBestMatch_generic ( const BYTE* const dictEnd = dictBase + dictLimit; const U32 current = (U32)(ip-base); const U32 maxDistance = 1U << cParams->windowLog; - const U32 lowValid = ms->window.lowLimit; - const U32 lowLimit = (current - lowValid > maxDistance) ? current - maxDistance : lowValid; + const U32 lowestValid = ms->window.lowLimit; + const U32 withinMaxDistance = (current - lowestValid > maxDistance) ? current - maxDistance : lowestValid; + const U32 isDictionary = (ms->loadedDictEnd != 0); + const U32 lowLimit = isDictionary ? lowestValid : withinMaxDistance; const U32 minChain = current > chainSize ? current - chainSize : 0; U32 nbAttempts = 1U << cParams->searchLog; size_t ml=4-1; @@ -642,8 +644,10 @@ ZSTD_compressBlock_lazy_generic( ZSTD_matchState_t* ms, const BYTE* ip, const BYTE* iLimit, size_t* offsetPtr); searchMax_f const searchMax = dictMode == ZSTD_dictMatchState ? - (searchMethod==search_binaryTree ? ZSTD_BtFindBestMatch_dictMatchState_selectMLS : ZSTD_HcFindBestMatch_dictMatchState_selectMLS) : - (searchMethod==search_binaryTree ? ZSTD_BtFindBestMatch_selectMLS : ZSTD_HcFindBestMatch_selectMLS); + (searchMethod==search_binaryTree ? ZSTD_BtFindBestMatch_dictMatchState_selectMLS + : ZSTD_HcFindBestMatch_dictMatchState_selectMLS) : + (searchMethod==search_binaryTree ? ZSTD_BtFindBestMatch_selectMLS + : ZSTD_HcFindBestMatch_selectMLS); U32 offset_1 = rep[0], offset_2 = rep[1], savedOffset=0; const ZSTD_matchState_t* const dms = ms->dictMatchState; diff --git a/tests/fuzzer.c b/tests/fuzzer.c index ab39d00e3..6338d6ae2 100644 --- a/tests/fuzzer.c +++ b/tests/fuzzer.c @@ -808,9 +808,9 @@ static int basicUnitTests(U32 seed, double compressibility) /* ZSTDMT simple MT compression test */ DISPLAYLEVEL(3, "test%3i : create ZSTDMT CCtx : ", testNb++); - { ZSTDMT_CCtx* mtctx = ZSTDMT_createCCtx(2); + { ZSTDMT_CCtx* const mtctx = ZSTDMT_createCCtx(2); if (mtctx==NULL) { - DISPLAY("mtctx : mot enough memory, aborting \n"); + DISPLAY("mtctx : not enough memory, aborting \n"); testResult = 1; goto _end; }