summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2017-10-20 20:44:49 (GMT)
committerYann Collet <cyan@fb.com>2017-10-20 20:44:49 (GMT)
commitd813134619d2d2cae09d0f8bb1629ef1206f269d (patch)
treee22255e93669b8e7d5fbba00322d52bd4f77b371 /lib
parentfa064c8a8c5f333a90232ecab0ef74b8cbf10476 (diff)
downloadlz4-d813134619d2d2cae09d0f8bb1629ef1206f269d.zip
lz4-d813134619d2d2cae09d0f8bb1629ef1206f269d.tar.gz
lz4-d813134619d2d2cae09d0f8bb1629ef1206f269d.tar.bz2
removed SET_PRICE macro
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4opt.h31
1 files changed, 14 insertions, 17 deletions
diff --git a/lib/lz4opt.h b/lib/lz4opt.h
index 488af90..dd4e15d 100644
--- a/lib/lz4opt.h
+++ b/lib/lz4opt.h
@@ -195,16 +195,6 @@ LZ4_FORCE_INLINE int LZ4HC_BinTree_GetAllMatches (
}
-#define SET_PRICE(pos, ml, offset, ll, cost) \
-{ \
- while (last_match_pos < pos) { opt[last_match_pos+1].price = 1<<30; last_match_pos++; } \
- opt[pos].mlen = (int)ml; \
- opt[pos].off = (int)offset; \
- opt[pos].litlen = (int)ll; \
- opt[pos].price = (int)cost; \
-}
-
-
static int LZ4HC_compress_optimal (
LZ4HC_CCtx_internal* ctx,
const char* const source,
@@ -319,22 +309,29 @@ static int LZ4HC_compress_optimal (
/* set prices using matches at position = cur */
{ size_t matchNb;
for (matchNb = 0; matchNb < nb_matches; matchNb++) {
- size_t ml = (matchNb>0) ? (size_t)matches[matchNb-1].len+1 : MINMATCH;
- size_t const matchML = (cur + matches[matchNb].len < LZ4_OPT_NUM) ?
- (size_t)matches[matchNb].len : LZ4_OPT_NUM - cur;
+ int ml = (matchNb>0) ? matches[matchNb-1].len+1 : MINMATCH;
+ int const matchML = (cur + matches[matchNb].len < LZ4_OPT_NUM) ?
+ matches[matchNb].len : (int)(LZ4_OPT_NUM - cur);
for ( ; ml <= matchML ; ml++) {
- size_t ll, price;
+ int const pos = cur + ml;
+ int const offset = matches[matchNb].off;
+ size_t price;
+ int ll;
if (opt[cur].mlen == 1) {
ll = opt[cur].litlen;
- price = ((cur > ll) ? opt[cur - ll].price : 0) + LZ4HC_sequencePrice(ll, ml);
+ price = ((cur > (size_t)ll) ? opt[cur - ll].price : 0) + LZ4HC_sequencePrice(ll, ml);
} else {
ll = 0;
price = opt[cur].price + LZ4HC_sequencePrice(0, ml);
}
- if (cur + ml > last_match_pos || price < (size_t)opt[cur + ml].price) {
- SET_PRICE(cur + ml, ml, matches[matchNb].off, ll, price);
+ if ((size_t)pos > last_match_pos || price < (size_t)opt[pos].price) {
+ while (last_match_pos < (size_t)pos) opt[++last_match_pos].price = 1<<30;
+ opt[pos].mlen = ml;
+ opt[pos].off = offset;
+ opt[pos].litlen = ll;
+ opt[pos].price = (int)price;
} } } }
} /* for (cur = 1; cur <= last_match_pos; cur++) */