Faster literals cost evaluation (suggested by @inikep)

dev
Yann Collet 2016-02-15 18:42:13 +01:00
parent e93add0439
commit 0068be94d8
1 changed files with 3 additions and 2 deletions

View File

@ -79,8 +79,9 @@ FORCE_INLINE U32 ZSTD_getLiteralPriceReal(seqStore_t* seqStorePtr, U32 litLength
if (!litLength) return 1; /* special case */ if (!litLength) return 1; /* special case */
/* literals */ /* literals */
for (u=0, price=0; u < litLength; u++) price = litLength * ZSTD_highbit(seqStorePtr->litSum);
price += ZSTD_highbit(seqStorePtr->litSum) - ZSTD_highbit(seqStorePtr->litFreq[literals[u]]); for (u=0; u < litLength; u++)
price -= ZSTD_highbit(seqStorePtr->litFreq[literals[u]]);
/* literal Length */ /* literal Length */
price += ((litLength >= MaxLL)*8) + ((litLength >= 255+MaxLL)*16) + ((litLength>=(1<<15))*8); price += ((litLength >= MaxLL)*8) + ((litLength >= 255+MaxLL)*16) + ((litLength>=(1<<15))*8);