From: Yann Collet Date: Tue, 28 Nov 2017 01:01:51 +0000 (-0800) Subject: btopt: minor speed optimization X-Git-Tag: v1.3.3^2~23^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9d1987fd7bbeb669fe23a6f396159b4579c9d21;p=thirdparty%2Fzstd.git btopt: minor speed optimization matchPrice is always right at beginning --- diff --git a/lib/compress/zstd_opt.c b/lib/compress/zstd_opt.c index 66a7da19c..459fe6571 100644 --- a/lib/compress/zstd_opt.c +++ b/lib/compress/zstd_opt.c @@ -523,14 +523,11 @@ size_t ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx, U32 const offset = matches[matchNb].off; U32 const end = matches[matchNb].len; repcodes_t const repHistory = ZSTD_updateRep(rep, offset, ll0); - while (pos <= end) { + for ( ; pos <= end ; pos++) { U32 const matchPrice = ZSTD_getPrice(optStatePtr, litlen, anchor, offset, pos, optLevel); - if (pos > last_pos || matchPrice < opt[pos].price) { - DEBUGLOG(7, "rPos:%u => set initial price : %u", - pos, matchPrice); - SET_PRICE(pos, pos, offset, litlen, matchPrice, repHistory); /* note : macro modifies last_pos */ - } - pos++; + DEBUGLOG(7, "rPos:%u => set initial price : %u", + pos, matchPrice); + SET_PRICE(pos, pos, offset, litlen, matchPrice, repHistory); /* note : macro modifies last_pos */ } } } }