From e9d1987fd7bbeb669fe23a6f396159b4579c9d21 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 27 Nov 2017 17:01:51 -0800 Subject: [PATCH] btopt: minor speed optimization matchPrice is always right at beginning --- lib/compress/zstd_opt.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) 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 */ } } } }