]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
[opt] Don't recompute initial literals price
authorNick Terrell <terrelln@fb.com>
Thu, 5 Mar 2020 00:12:16 +0000 (16:12 -0800)
committerNick Terrell <terrelln@fb.com>
Thu, 5 Mar 2020 00:27:17 +0000 (16:27 -0800)
lib/compress/zstd_opt.c

index 2e50fca6ff53f5790d85aaaec737961c492fdaca..44a13ddb77850fd98c4454aa3bffb81c4278bb1b 100644 (file)
@@ -270,19 +270,6 @@ static int ZSTD_litLengthContribution(U32 const litLength, const optState_t* con
     }
 }
 
-/* ZSTD_literalsContribution() :
- * creates a fake cost for the literals part of a sequence
- * which can be compared to the ending cost of a match
- * should a new match start at this position */
-static int ZSTD_literalsContribution(const BYTE* const literals, U32 const litLength,
-                                     const optState_t* const optPtr,
-                                     int optLevel)
-{
-    int const contribution = (int)ZSTD_rawLiteralsCost(literals, litLength, optPtr, optLevel)
-                           + ZSTD_litLengthContribution(litLength, optPtr, optLevel);
-    return contribution;
-}
-
 /* ZSTD_getMatchPrice() :
  * Provides the cost of the match part (offset + matchLength) of a sequence
  * Must be combined with ZSTD_fullLiteralsCost() to get the full cost of a sequence.
@@ -894,7 +881,7 @@ ZSTD_compressBlock_opt_generic(ZSTD_matchState_t* ms,
             { U32 i ; for (i=0; i<ZSTD_REP_NUM; i++) opt[0].rep[i] = rep[i]; }
             opt[0].mlen = 0;  /* means is_a_literal */
             opt[0].litlen = litlen;
-            opt[0].price = ZSTD_literalsContribution(anchor, litlen, optStatePtr, optLevel);
+            opt[0].price = ZSTD_litLengthPrice(litlen, optStatePtr, optLevel);
 
             /* large match -> immediate encoding */
             {   U32 const maxML = matches[nbMatches-1].len;