]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
minor code cleaning for new index invalidation strategy
authorYann Collet <cyan@fb.com>
Fri, 31 May 2019 23:52:37 +0000 (16:52 -0700)
committerYann Collet <cyan@fb.com>
Fri, 31 May 2019 23:52:37 +0000 (16:52 -0700)
lib/compress/zstd_compress.c
lib/compress/zstd_compress_internal.h

index 46400f78a45c95970e68daa8b53d0baaa46cf660..7d31db72c6d8c6bf9742d214fa9ee11ba8663ffe 100644 (file)
@@ -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;
 
index 6e3021080b3b686ef97b1295eac03d5e0c0a4724..55304fa317fd53ea93b3737d1ac74fea0746327f 100644 (file)
@@ -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;