]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Existing Repcode Check Only Applies to noDict Case
authorW. Felix Handte <w@felixhandte.com>
Wed, 9 May 2018 20:46:57 +0000 (16:46 -0400)
committerW. Felix Handte <w@felixhandte.com>
Fri, 25 May 2018 17:13:28 +0000 (13:13 -0400)
lib/compress/zstd_double_fast.c

index 2bcd4b5d0608707c23e59a5aed6a8a2fce51c573..0b8cba13e04910ad844d97c6c68226723b0a45d1 100644 (file)
@@ -112,8 +112,8 @@ size_t ZSTD_compressBlock_doubleFast_generic(
         const BYTE* match = base + matchIndexS;
         hashLong[h2] = hashSmall[h] = current;   /* update hash tables */
 
-        assert(offset_1 <= current);   /* supposed guaranteed by construction */
-        if ((offset_1 > 0) & (MEM_read32(ip+1-offset_1) == MEM_read32(ip+1))) {
+        if (dictMode == ZSTD_noDict && ((offset_1 > 0) & (MEM_read32(ip+1-offset_1) == MEM_read32(ip+1)))) {
+            assert(offset_1 <= current);   /* supposed guaranteed by construction */
             /* favor repcode */
             mLength = ZSTD_count(ip+1+4, ip+1+4-offset_1, iend) + 4;
             ip++;
@@ -162,7 +162,8 @@ size_t ZSTD_compressBlock_doubleFast_generic(
                 hashSmall[ZSTD_hashPtr(ip-2, hBitsS, mls)] = (U32)(ip-2-base);
 
             /* check immediate repcode */
-            while ( (ip <= ilimit)
+            while ( dictMode == ZSTD_noDict
+                 && (ip <= ilimit)
                  && ( (offset_2>0)
                  & (MEM_read32(ip) == MEM_read32(ip - offset_2)) )) {
                 /* store sequence */