From a968099038e0ee3b939c5aa1084074c0f14f43c4 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Fri, 31 May 2019 16:52:37 -0700 Subject: [PATCH] minor code cleaning for new index invalidation strategy --- lib/compress/zstd_compress.c | 2 +- lib/compress/zstd_compress_internal.h | 16 +++------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index 46400f78a..7d31db72c 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -2868,8 +2868,8 @@ static size_t ZSTD_compress_frameChunk (ZSTD_CCtx* cctx, ms->dictMatchState = NULL; } - //ZSTD_window_enforceMaxDist(&ms->window, ip + blockSize, maxDist, &ms->loadedDictEnd, &ms->dictMatchState); ZSTD_checkDictValidity(&ms->window, ip + blockSize, maxDist, &ms->loadedDictEnd, &ms->dictMatchState); + /* Ensure hash/chain table insertion resumes no sooner than lowlimit */ if (ms->nextToUpdate < ms->window.lowLimit) ms->nextToUpdate = ms->window.lowLimit; diff --git a/lib/compress/zstd_compress_internal.h b/lib/compress/zstd_compress_internal.h index 6e3021080..55304fa31 100644 --- a/lib/compress/zstd_compress_internal.h +++ b/lib/compress/zstd_compress_internal.h @@ -731,6 +731,9 @@ ZSTD_window_enforceMaxDist(ZSTD_window_t* window, } } +/* Similar to ZSTD_window_enforceMaxDist(), + * but only invalidates dictionary + * when input progresses beyond window size. */ MEM_STATIC void ZSTD_checkDictValidity(ZSTD_window_t* window, const void* blockEnd, @@ -743,19 +746,6 @@ ZSTD_checkDictValidity(ZSTD_window_t* window, DEBUGLOG(5, "ZSTD_checkDictValidity: blockEndIdx=%u, maxDist=%u, loadedDictEnd=%u", (unsigned)blockEndIdx, (unsigned)maxDist, (unsigned)loadedDictEnd); - /* - When there is no dictionary : loadedDictEnd == 0. - In which case, the test (blockEndIdx > maxDist) is merely to avoid - overflowing next operation `newLowLimit = blockEndIdx - maxDist`. - - When there is a standard dictionary : - Index referential is copied from the dictionary, - which means it starts from 0. - In which case, loadedDictEnd == dictSize, - and it makes sense to compare `blockEndIdx > maxDist + dictSize` - since `blockEndIdx` also starts from zero. - - When there is an attached dictionary : - loadedDictEnd is expressed within the referential of the context, - so it can be directly compared against blockEndIdx. - */ if (loadedDictEnd && (blockEndIdx > maxDist + loadedDictEnd)) { /* On reaching window size, dictionaries are invalidated */ if (loadedDictEndPtr) *loadedDictEndPtr = 0; -- 2.47.3