]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
btopt0 : a bit faster and weaker
authorYann Collet <cyan@fb.com>
Sun, 19 Nov 2017 18:38:02 +0000 (10:38 -0800)
committerYann Collet <cyan@fb.com>
Sun, 19 Nov 2017 18:38:02 +0000 (10:38 -0800)
lib/compress/zstd_opt.c

index ed85279895f13d66621f92d8cb7c2d0b209a2fe1..c62b8897cbb14957825d9d23ca2ac4c68681dff0 100644 (file)
@@ -553,11 +553,15 @@ size_t ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx,
                     SET_PRICE(cur, 1/*mlen*/, 0/*offset*/, litlen, price, opt[cur-1].rep);
             }   }
 
-            if (cur == last_pos) break;
-
             /* last match must start at a minimum distance of 8 from oend */
             if (inr > ilimit) continue;
 
+            if (cur == last_pos) break;
+
+             if ( (optLevel==0) /*static*/
+               && (opt[cur+1].price <= opt[cur].price) )
+                continue;  /* skip unpromising positions; about ~+6% speed, -0.01 ratio */
+
             {   U32 const ll0 = (opt[cur].mlen != 1);
                 U32 const litlen = (opt[cur].mlen == 1) ? opt[cur].litlen : 0;
                 U32 const basePrice = (cur > litlen) ? opt[cur-litlen].price : 0;
@@ -600,7 +604,7 @@ size_t ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx,
                                         pos, price, opt[pos].price);
                             SET_PRICE(pos, mlen, offset, litlen, price, repHistory);  /* note : macro modifies last_pos */
                         } else {
-                            if (optLevel==0) break;  /* gets ~+10% speed for about 0.01 ratio loss */
+                            if (optLevel==0) break;  /* gets ~+10% speed for about -0.01 ratio loss */
                         }
         }   }   }   }