From: W. Felix Handte Date: Tue, 10 Sep 2019 21:55:41 +0000 (-0400) Subject: Only Reset Indexing in `ZSTD_resetCCtx_internal()` When Necessary X-Git-Tag: v1.4.4~1^2~49^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f31ef28ff894c9ccdbac1dbc611cb9e702d71738;p=thirdparty%2Fzstd.git Only Reset Indexing in `ZSTD_resetCCtx_internal()` When Necessary --- diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index 21b13fa80..ec7e78363 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -1398,6 +1398,14 @@ static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc, size_t const matchStateSize = ZSTD_sizeof_matchState(¶ms.cParams, /* forCCtx */ 1); size_t const maxNbLdmSeq = ZSTD_ldm_getMaxNbSeq(params.ldmParams, blockSize); + ZSTD_indexResetPolicy_e needsIndexReset = ZSTDirp_continue; + + if (ZSTD_indexTooCloseToMax(zc->blockState.matchState.window)) { + needsIndexReset = ZSTDirp_reset; + } + + ZSTD_cwksp_bump_oversized_duration(ws, 0); + /* Check if workspace is large enough, alloc a new one if needed */ { size_t const cctxSpace = zc->staticSize ? sizeof(ZSTD_CCtx) : 0; size_t const entropySpace = HUF_WORKSPACE_SIZE; @@ -1430,6 +1438,8 @@ static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc, RETURN_ERROR_IF(zc->staticSize, memory_allocation, "static cctx : no resize"); + needsIndexReset = ZSTDirp_reset; + ZSTD_cwksp_free(ws, zc->customMem); FORWARD_IF_ERROR(ZSTD_cwksp_create(ws, neededSpace, zc->customMem)); @@ -1500,7 +1510,7 @@ static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc, ws, ¶ms.cParams, crp, - ZSTDirp_reset, + needsIndexReset, ZSTD_resetTarget_CCtx)); /* ldm hash table */