]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
minor speed improvements
authorinikep <inikep@gmail.com>
Thu, 7 Apr 2016 09:35:17 +0000 (11:35 +0200)
committerinikep <inikep@gmail.com>
Thu, 7 Apr 2016 09:35:17 +0000 (11:35 +0200)
lib/zstd_compress.c
lib/zstd_opt.h

index 40973735499f06c7421a70ab686f4f246558b808..d353c39365578b5a203dab756929b2928dc98d34 100644 (file)
@@ -1319,6 +1319,7 @@ size_t ZSTD_HcFindBestMatch_generic (
     const U32 minMatch = (mls == 3) ? 3 : 4;
     size_t ml=minMatch-1;
 
+#if 0
     if (minMatch == 3) { /* HC3 match finder */
         U32 const matchIndex3 = ZSTD_insertAndFindFirstIndexHash3 (zc, ip);
         if (matchIndex3>lowLimit && current - matchIndex3<(1<<18)) {
@@ -1326,8 +1327,7 @@ size_t ZSTD_HcFindBestMatch_generic (
             size_t currentMl=0;
             if ((!extDict) || matchIndex3 >= dictLimit) {
                 match = base + matchIndex3;
-                if (match[ml] == ip[ml])   /* potentially better */
-                    currentMl = ZSTD_count(ip, match, iLimit);
+                if (match[ml] == ip[ml]) currentMl = ZSTD_count(ip, match, iLimit); /* potentially better */
             } else {
                 match = dictBase + matchIndex3;
                 if (MEM_readMINMATCH(match, MINMATCH) == MEM_readMINMATCH(ip, MINMATCH))   /* assumption : matchIndex3 <= dictLimit-4 (by table construction) */
@@ -1335,9 +1335,12 @@ size_t ZSTD_HcFindBestMatch_generic (
             }
 
             /* save best solution */
-            if (currentMl > ml) { ml = currentMl; *offsetPtr = ZSTD_REP_MOVE + current - matchIndex3; if (ip+currentMl == iLimit) return (ml>=MINMATCH) ? ml : 0; /* best possible, and avoid read overflow*/ }
-        }
+            if (currentMl > ml) { 
+                ml = currentMl; *offsetPtr = ZSTD_REP_MOVE + current - matchIndex3; 
+                if (ip+currentMl == iLimit) return (ml>=MINMATCH) ? ml : 0; /* best possible, and avoid read overflow*/ 
+        }   }
     }
+#endif
 
     /* HC4 match finder */
     U32 matchIndex = ZSTD_insertAndFindFirstIndex (zc, ip, mls);
@@ -1536,7 +1539,7 @@ static size_t ZSTD_insertBtAndFindBestMatch (
     size_t bestLength = minMatch-1;
 
     if (minMatch == 3) { /* HC3 match finder */
-        U32 matchIndex3 = ZSTD_insertAndFindFirstIndexHash3 (zc, ip);
+        U32 const matchIndex3 = ZSTD_insertAndFindFirstIndexHash3 (zc, ip);
         if (matchIndex3>windowLow && (current - matchIndex3 < (1<<18))) {
             const BYTE* match;
             size_t currentMl=0;
@@ -1545,8 +1548,8 @@ static size_t ZSTD_insertBtAndFindBestMatch (
                 if (match[bestLength] == ip[bestLength]) currentMl = ZSTD_count(ip, match, iend);
             } else {
                 match = dictBase + matchIndex3;
-                if (MEM_readMINMATCH(match, minMatch) == MEM_readMINMATCH(ip, minMatch))    /* assumption : matchIndex3 <= dictLimit-4 (by table construction) */
-                    currentMl = ZSTD_count_2segments(ip+minMatch, match+minMatch, iend, dictEnd, prefixStart) + minMatch;
+                if (MEM_readMINMATCH(match, MINMATCH) == MEM_readMINMATCH(ip, MINMATCH))    /* assumption : matchIndex3 <= dictLimit-4 (by table construction) */
+                    currentMl = ZSTD_count_2segments(ip+MINMATCH, match+MINMATCH, iend, dictEnd, prefixStart) + MINMATCH;
             }
 
             /* save best solution */
index 88d7a69755b1b0c4b80d2955cc9ce305325b5b48..2c7df9f591ef7eb4e1f5b21bb53f309ee77d7250 100644 (file)
@@ -247,8 +247,7 @@ static U32 ZSTD_insertBtAndGetAllMatches (
     size_t bestLength = minMatch-1;
 
     if (minMatch == 3) { /* HC3 match finder */
-        U32 matchIndex3 = ZSTD_insertAndFindFirstIndexHash3 (zc, ip);
-
+        U32 const matchIndex3 = ZSTD_insertAndFindFirstIndexHash3 (zc, ip);
         if (matchIndex3>windowLow && (current - matchIndex3 < (1<<18))) {
             const BYTE* match;
             size_t currentMl=0;
@@ -257,8 +256,8 @@ static U32 ZSTD_insertBtAndGetAllMatches (
                 if (match[bestLength] == ip[bestLength]) currentMl = ZSTD_count(ip, match, iLimit);
             } else {
                 match = dictBase + matchIndex3;
-                if (MEM_readMINMATCH(match, minMatch) == MEM_readMINMATCH(ip, minMatch))    /* assumption : matchIndex3 <= dictLimit-4 (by table construction) */
-                    currentMl = ZSTD_count_2segments(ip+minMatch, match+minMatch, iLimit, dictEnd, prefixStart) + minMatch;
+                if (MEM_readMINMATCH(match, MINMATCH) == MEM_readMINMATCH(ip, MINMATCH))    /* assumption : matchIndex3 <= dictLimit-4 (by table construction) */
+                    currentMl = ZSTD_count_2segments(ip+MINMATCH, match+MINMATCH, iLimit, dictEnd, prefixStart) + MINMATCH;
             }
 
             /* save best solution */