]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
adding dedicated dict load method to lazy
authorBimba Shrestha <bimbashrestha@fb.com>
Fri, 12 Jun 2020 01:27:07 +0000 (18:27 -0700)
committerW. Felix Handte <w@felixhandte.com>
Thu, 10 Sep 2020 22:51:52 +0000 (18:51 -0400)
lib/compress/zstd_lazy.c
lib/compress/zstd_lazy.h

index 6371863f35d50201728fbe1eb653b8e3dd24a136..b1171f147a6a058dcc641503992f50045bb159a9 100644 (file)
@@ -475,6 +475,25 @@ U32 ZSTD_insertAndFindFirstIndex(ZSTD_matchState_t* ms, const BYTE* ip) {
     return ZSTD_insertAndFindFirstIndex_internal(ms, cParams, ip, ms->cParams.minMatch);
 }
 
+void ZSTD_lazy_loadDictionary(ZSTD_matchState_t* ms, const BYTE* const ip)
+{
+    U32 const target = (U32)(ip - ms->window.base);
+    U32* const chainTable = ms->chainTable;
+    U32 const chainMask = (1 << ms->cParams.chainLog) - 1;
+    for (U32 idx = ms->nextToUpdate; idx < target; idx++) {
+        U32 const h = ZSTD_hashPtr(
+            ms->window.base + idx,
+            ms->cParams.hashLog - DD_BLOG,
+            ms->cParams.minMatch) << DD_BLOG;
+        chainTable[idx & chainMask] = ms->hashTable[h];
+        ms->hashTable[h] = idx;
+        /* Same logic as before. But now, just copy the into bucket */
+        for (U32 i = 0; i < (1 << DD_BLOG); i++)
+            ms->hashTable[h + i] = chainTable[ms->hashTable[h + i] & chainMask];
+    }
+    ms->nextToUpdate = target;
+}
+
 
 /* inlining is important to hardwire a hot branch (template emulation) */
 FORCE_INLINE_TEMPLATE
index 581936f03bd4be6e792b2d418fef19bb652395bd..74e9368e7b67cbe7becfca658e411f47ac504fba 100644 (file)
@@ -19,6 +19,8 @@ extern "C" {
 
 U32 ZSTD_insertAndFindFirstIndex(ZSTD_matchState_t* ms, const BYTE* ip);
 
+void ZSTD_lazy_loadDictionary(ZSTD_matchState_t* ms, const BYTE* const ip);
+
 void ZSTD_preserveUnsortedMark (U32* const table, U32 const size, U32 const reducerValue);  /*! used in ZSTD_reduceIndex(). preemptively increase value of ZSTD_DUBT_UNSORTED_MARK */
 
 size_t ZSTD_compressBlock_btlazy2(