diff options
author | Yann Collet <cyan@fb.com> | 2017-05-02 05:32:21 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2017-05-02 05:32:21 (GMT) |
commit | a8dd86d93e963edd6761936377dff21b45016156 (patch) | |
tree | 0c0c5f5c2854506e44c1fb1b140cefe10ca3e15a /lib/lz4opt.h | |
parent | 11bfedb6c3b30b71c54e15ecbde9fab396d444e5 (diff) | |
download | lz4-a8dd86d93e963edd6761936377dff21b45016156.zip lz4-a8dd86d93e963edd6761936377dff21b45016156.tar.gz lz4-a8dd86d93e963edd6761936377dff21b45016156.tar.bz2 |
changed macro HEAPMODE into LZ4_HEAPMODE
This macro is susceptible to be triggered from user side
typically through compiler flag (-DLZ4_HEAPMODE=1).
In which case, it makes sense to prefix the macro
since we want to reduce potential side-effect on namespace.
Diffstat (limited to 'lib/lz4opt.h')
-rw-r--r-- | lib/lz4opt.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/lz4opt.h b/lib/lz4opt.h index 416241a..b346eba 100644 --- a/lib/lz4opt.h +++ b/lib/lz4opt.h @@ -49,11 +49,12 @@ typedef struct { } LZ4HC_optimal_t; -/* price in bits */ +/* price in bytes */ FORCE_INLINE size_t LZ4HC_literalsPrice(size_t litlen) { size_t price = litlen; - if (litlen >= (size_t)RUN_MASK) price += 1 + (litlen-RUN_MASK)/255; + if (litlen >= (size_t)RUN_MASK) + price += 1 + (litlen-RUN_MASK)/255; return price; } @@ -66,7 +67,7 @@ FORCE_INLINE size_t LZ4HC_sequencePrice(size_t litlen, size_t mlen) price += LZ4HC_literalsPrice(litlen); if (mlen >= (size_t)(ML_MASK+MINMATCH)) - price+= 1+(mlen-(ML_MASK+MINMATCH))/255; + price+= 1 + (mlen-(ML_MASK+MINMATCH))/255; return price; } @@ -232,7 +233,7 @@ static int LZ4HC_compress_optimal ( size_t const llen = ip - anchor; size_t last_pos = 0; size_t match_num, cur, best_mlen, best_off; - memset(opt, 0, sizeof(LZ4HC_optimal_t)); + memset(opt, 0, sizeof(LZ4HC_optimal_t)); /* memset only the first one */ match_num = LZ4HC_BinTree_GetAllMatches(ctx, ip, matchlimit, MINMATCH-1, matches, fullUpdate); if (!match_num) { ip++; continue; } @@ -279,7 +280,7 @@ static int LZ4HC_compress_optimal ( } if (price < (size_t)opt[cur].price) - SET_PRICE(cur, 1, 0, litlen, price); /* note : increases last_pos */ + SET_PRICE(cur, 1 /*mlen*/, 0 /*off*/, litlen, price); /* note : increases last_pos */ } if (cur == last_pos || curPtr >= mflimit) break; @@ -331,7 +332,7 @@ encode: /* cur, last_pos, best_mlen, best_off must be set */ opt[cur].off = (int)best_off; best_mlen = ml; best_off = offset; - if (ml > cur) break; + if (ml > cur) break; /* can this happen ? */ cur -= ml; } |