From: Yann Collet Date: Sun, 19 Nov 2017 18:38:02 +0000 (-0800) Subject: btopt0 : a bit faster and weaker X-Git-Tag: v1.3.3^2~32^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d100670045fb39adcce509d4bbb3ceb4a0091975;p=thirdparty%2Fzstd.git btopt0 : a bit faster and weaker --- diff --git a/lib/compress/zstd_opt.c b/lib/compress/zstd_opt.c index ed8527989..c62b8897c 100644 --- a/lib/compress/zstd_opt.c +++ b/lib/compress/zstd_opt.c @@ -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 */ } } } } }