summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2022-09-30 01:48:03 (GMT)
committerYann Collet <cyan@fb.com>2022-09-30 01:48:03 (GMT)
commit2fefb1da619898d996c5a75f98fc1e8cdf28f31c (patch)
treecaff8fc4f870589095b70b39bc0ad0db087cd19f
parent0a2e406d82b5fbef988a2880a7f7e18e33622394 (diff)
downloadlz4-2fefb1da619898d996c5a75f98fc1e8cdf28f31c.zip
lz4-2fefb1da619898d996c5a75f98fc1e8cdf28f31c.tar.gz
lz4-2fefb1da619898d996c5a75f98fc1e8cdf28f31c.tar.bz2
removed virtual pointer from optimal parser
replaced by direct offset value. this virtual pointer was only used in rare _dstSize scenario.
-rw-r--r--lib/lz4hc.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c
index bdd4d1e..134d850 100644
--- a/lib/lz4hc.c
+++ b/lib/lz4hc.c
@@ -1378,7 +1378,7 @@ static int LZ4HC_compress_optimal ( LZ4HC_CCtx_internal* ctx,
BYTE* opSaved = (BYTE*) dst;
BYTE* oend = op + dstCapacity;
int ovml = MINMATCH; /* overflow - last sequence */
- const BYTE* ovref = NULL;
+ int ovoff = 0;
/* init */
#if defined(LZ4HC_HEAPMODE) && LZ4HC_HEAPMODE==1
@@ -1401,11 +1401,10 @@ static int LZ4HC_compress_optimal ( LZ4HC_CCtx_internal* ctx,
if ((size_t)firstMatch.len > sufficient_len) {
/* good enough solution : immediate encoding */
int const firstML = firstMatch.len;
- const BYTE* const matchPos = ip - firstMatch.off;
opSaved = op;
if ( LZ4HC_encodeSequence(UPDATABLE(ip, op, anchor), firstML, firstMatch.off, limit, oend) ) { /* updates ip, op and anchor */
ovml = firstML;
- ovref = matchPos;
+ ovoff = firstMatch.off;
goto _dest_overflow;
}
continue;
@@ -1581,7 +1580,7 @@ encode: /* cur, last_match_pos, best_mlen, best_off must be set */
opSaved = op;
if ( LZ4HC_encodeSequence(UPDATABLE(ip, op, anchor), ml, offset, limit, oend) ) { /* updates ip, op and anchor */
ovml = ml;
- ovref = ip - offset;
+ ovoff = offset;
goto _dest_overflow;
} } }
} /* while (ip <= mflimit) */
@@ -1640,7 +1639,7 @@ if (limit == fillOutput) {
if ((oend + LASTLITERALS) - (op + ll_totalCost + 2) - 1 + ovml >= MFLIMIT) {
DEBUGLOG(6, "Space to end : %i + ml (%i)", (int)((oend + LASTLITERALS) - (op + ll_totalCost + 2) - 1), ovml);
DEBUGLOG(6, "Before : ip = %p, anchor = %p", ip, anchor);
- LZ4HC_encodeSequence(UPDATABLE(ip, op, anchor), ovml, (int)(ip - ovref), notLimited, oend);
+ LZ4HC_encodeSequence(UPDATABLE(ip, op, anchor), ovml, ovoff, notLimited, oend);
DEBUGLOG(6, "After : ip = %p, anchor = %p", ip, anchor);
} }
goto _last_literals;