diff options
Diffstat (limited to 'lib/lz4opt.h')
-rw-r--r-- | lib/lz4opt.h | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/lib/lz4opt.h b/lib/lz4opt.h index c9fab04..0463cb1 100644 --- a/lib/lz4opt.h +++ b/lib/lz4opt.h @@ -46,7 +46,6 @@ typedef struct { int off; int mlen; int litlen; - int toSearch; } LZ4HC_optimal_t; @@ -244,6 +243,7 @@ static int LZ4HC_compress_optimal ( const BYTE* const matchlimit = iend - LASTLITERALS; BYTE* op = (BYTE*) dst; BYTE* const oend = op + dstCapacity; + int const front = fullUpdate ? 2 : 1; /* init */ DEBUGLOG(5, "LZ4HC_compress_optimal"); @@ -279,7 +279,6 @@ static int LZ4HC_compress_optimal ( opt[rPos].off = 0; opt[rPos].litlen = llen + rPos; opt[rPos].price = cost; - opt[rPos].toSearch = 1; DEBUGLOG(7, "rPos:%3i => price:%3i (litlen=%i) -- initial setup", rPos, cost, opt[rPos].litlen); } } @@ -296,21 +295,16 @@ static int LZ4HC_compress_optimal ( opt[mlen].off = offset; opt[mlen].litlen = llen; opt[mlen].price = cost; - opt[mlen].toSearch = (((mlen - 18) % 255) == 0); DEBUGLOG(7, "rPos:%3i => price:%3i (matchlen=%i) -- initial setup", mlen, cost, mlen); } } } last_match_pos = matches[nb_matches_initial-1].len; - if (fullUpdate) opt[last_match_pos-2].toSearch = 1; /* 1 byte on calgary */ - if (fullUpdate) opt[last_match_pos-1].toSearch = 1; /* 1 byte on calgary */ - opt[last_match_pos].toSearch = 1; { int addLit; for (addLit = 1; addLit <= 3; addLit ++) { opt[last_match_pos+addLit].mlen = 1; /* literal */ opt[last_match_pos+addLit].off = 0; opt[last_match_pos+addLit].litlen = addLit; opt[last_match_pos+addLit].price = opt[last_match_pos].price + LZ4HC_literalsPrice(addLit); - opt[last_match_pos+addLit].toSearch = 1; DEBUGLOG(7, "rPos:%3i => price:%3i (litlen=%i) -- initial setup", last_match_pos+addLit, opt[last_match_pos+addLit].price, addLit); } } @@ -321,7 +315,9 @@ static int LZ4HC_compress_optimal ( int nb_matches; if (curPtr >= mflimit) break; - if (opt[cur].toSearch == 0) continue; + DEBUGLOG(7, "rPos:%u[%u] vs [%u]%u", + cur, opt[cur].price, opt[cur+1].price, cur+1); + if (opt[cur+front].price <= opt[cur].price) continue; DEBUGLOG(7, "search at rPos:%u", cur); //nb_matches = LZ4HC_BinTree_GetAllMatches(ctx, curPtr, matchlimit, MINMATCH-1, matches, fullUpdate); @@ -388,19 +384,14 @@ static int LZ4HC_compress_optimal ( opt[pos].off = offset; opt[pos].litlen = ll; opt[pos].price = price; - opt[pos].toSearch = (((ml-18) % 255) == 0); } } } } /* complete following positions with literals */ - if (fullUpdate) opt[last_match_pos-2].toSearch = 1; /* 2 bytes on enwik7 */ - if (fullUpdate) opt[last_match_pos-1].toSearch = 1; /* 53 bytes on enwik7, 13 bytes on calgary */ - opt[last_match_pos].toSearch = 1; { int addLit; for (addLit = 1; addLit <= 3; addLit ++) { opt[last_match_pos+addLit].mlen = 1; /* literal */ opt[last_match_pos+addLit].off = 0; opt[last_match_pos+addLit].litlen = addLit; opt[last_match_pos+addLit].price = opt[last_match_pos].price + LZ4HC_literalsPrice(addLit); - opt[last_match_pos+addLit].toSearch = 1; DEBUGLOG(7, "rPos:%3i => price:%3i (litlen=%i)", last_match_pos+addLit, opt[last_match_pos+addLit].price, addLit); } } } /* for (cur = 1; cur <= last_match_pos; cur++) */ |