]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Misc Changes
authorW. Felix Handte <w@felixhandte.com>
Thu, 14 Jun 2018 20:59:49 +0000 (16:59 -0400)
committerW. Felix Handte <w@felixhandte.com>
Tue, 19 Jun 2018 17:01:21 +0000 (13:01 -0400)
lib/compress/zstd_opt.c

index bd740f85437febed3ac2c026027baabe7b1a682f..ea80d78050a24b6d71a74253335c38020abd7a8d 100644 (file)
@@ -612,7 +612,8 @@ U32 ZSTD_insertBtAndGetAllMatches (
             U32 const hashLog3 = ms->hashLog3;
             size_t const hash3 = ZSTD_hash3Ptr(ip, hashLog3);
             U32 const dmsMatchIndex3 = dms->hashTable3[hash3];
-            if (dmsMatchIndex3 >= dmsLowLimit) {
+            matchIndex3 = dmsMatchIndex3 + dmsIndexDelta;
+            if ((dmsMatchIndex3 >= dmsLowLimit) & (current - matchIndex3 < (1<<18))) {
                 const BYTE* const match = dmsBase + dmsMatchIndex3;
                 size_t mlen = ZSTD_count_2segments(ip, match, iLimit, dmsEnd, prefixStart);
                 if (mlen >= mls) {
@@ -664,8 +665,8 @@ U32 ZSTD_insertBtAndGetAllMatches (
             matches[mnum].off = (current - matchIndex) + ZSTD_REP_MOVE;
             matches[mnum].len = (U32)matchLength;
             mnum++;
-            if ( matchLength > ZSTD_OPT_NUM
-               | ip+matchLength == iLimit /* equal : no way to know if inf or sup */) {
+            if ( (matchLength > ZSTD_OPT_NUM)
+               | (ip+matchLength == iLimit) /* equal : no way to know if inf or sup */) {
                 if (dictMode == ZSTD_dictMatchState) nbCompares = 0; /* break should also skip searching dms */
                 break; /* drop, to preserve bt consistency (miss a little bit of compression) */
             }
@@ -709,19 +710,18 @@ U32 ZSTD_insertBtAndGetAllMatches (
                 matches[mnum].off = (current - matchIndex) + ZSTD_REP_MOVE;
                 matches[mnum].len = (U32)matchLength;
                 mnum++;
-                if ( matchLength > ZSTD_OPT_NUM
-                   | ip+matchLength == iLimit /* equal : no way to know if inf or sup */) {
+                if ( (matchLength > ZSTD_OPT_NUM)
+                   | (ip+matchLength == iLimit) /* equal : no way to know if inf or sup */) {
                     break;   /* drop, to guarantee consistency (miss a little bit of compression) */
                 }
             }
 
+            if (dictMatchIndex <= btLow) { break; }   /* beyond tree size, stop the search */
             if (match[matchLength] < ip[matchLength]) {
-                if (dictMatchIndex <= btLow) { break; }   /* beyond tree size, stop the search */
                 commonLengthSmaller = matchLength;    /* all smaller will now have at least this guaranteed common length */
                 dictMatchIndex = nextPtr[1];              /* new matchIndex larger than previous (closer to current) */
             } else {
                 /* match is larger than current */
-                if (dictMatchIndex <= btLow) { break; }   /* beyond tree size, stop the search */
                 commonLengthLarger = matchLength;
                 dictMatchIndex = nextPtr[0];
             }