]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Support a Separate Hash Log in ZSTD_fast
authorW. Felix Handte <w@felixhandte.com>
Thu, 23 Aug 2018 21:49:09 +0000 (14:49 -0700)
committerW. Felix Handte <w@felixhandte.com>
Sat, 29 Sep 2018 00:12:54 +0000 (17:12 -0700)
lib/compress/zstd_fast.c

index bb7234846c26b9b087ef375485fd9c131ab3bf3f..dfb46abe4cd0db7d479ea25d7dbf2eda14afe230 100644 (file)
@@ -64,6 +64,9 @@ size_t ZSTD_compressBlock_fast_generic(
     U32 offsetSaved = 0;
 
     const ZSTD_matchState_t* const dms = ms->dictMatchState;
+    const ZSTD_compressionParameters* const dictCParams =
+                                     dictMode == ZSTD_dictMatchState ?
+                                     &dms->cParams : NULL;
     const U32* const dictHashTable = dictMode == ZSTD_dictMatchState ?
                                      dms->hashTable : NULL;
     const U32 dictStartIndex       = dictMode == ZSTD_dictMatchState ?
@@ -78,6 +81,8 @@ size_t ZSTD_compressBlock_fast_generic(
                                      prefixStartIndex - (U32)(dictEnd - dictBase) :
                                      0;
     const U32 dictAndPrefixLength  = (U32)(ip - prefixStart + dictEnd - dictStart);
+    const U32 dictHLog             = dictMode == ZSTD_dictMatchState ?
+                                     dictCParams->hashLog : 0;
 
     assert(dictMode == ZSTD_noDict || dictMode == ZSTD_dictMatchState);
 
@@ -128,7 +133,8 @@ size_t ZSTD_compressBlock_fast_generic(
             ZSTD_storeSeq(seqStore, ip-anchor, anchor, 0, mLength-MINMATCH);
         } else if ( (matchIndex <= prefixStartIndex) ) {
             if (dictMode == ZSTD_dictMatchState) {
-                U32 const dictMatchIndex = dictHashTable[h];
+                size_t const dictHash = ZSTD_hashPtr(ip, dictHLog, mls);
+                U32 const dictMatchIndex = dictHashTable[dictHash];
                 const BYTE* dictMatch = dictBase + dictMatchIndex;
                 if (dictMatchIndex <= dictStartIndex ||
                     MEM_read32(dictMatch) != MEM_read32(ip)) {