]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
btopt: minor speed optimization
authorYann Collet <cyan@fb.com>
Tue, 28 Nov 2017 01:01:51 +0000 (17:01 -0800)
committerYann Collet <cyan@fb.com>
Tue, 28 Nov 2017 01:01:51 +0000 (17:01 -0800)
matchPrice is always right at beginning

lib/compress/zstd_opt.c

index 66a7da19c8eeb8b8d988c040192f9343948ce7a8..459fe65713c68584a1994f122b97bcaa06fb1dcc 100644 (file)
@@ -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 */
             }   }   }
         }