summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2017-10-25 05:07:08 (GMT)
committerYann Collet <cyan@fb.com>2017-10-25 05:07:08 (GMT)
commit16a433747309d209c2247c5074ff3ac8783548c7 (patch)
treec9991f5e73720662f008f93f758c4c7ff39ea6ce /lib
parenta12cdf00c3d0a0e3e7b2638d4a256f14b15c0072 (diff)
downloadlz4-16a433747309d209c2247c5074ff3ac8783548c7.zip
lz4-16a433747309d209c2247c5074ff3ac8783548c7.tar.gz
lz4-16a433747309d209c2247c5074ff3ac8783548c7.tar.bz2
added hash chain with conditional length
not a success yet
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4hc.c9
-rw-r--r--lib/lz4opt.h3
2 files changed, 2 insertions, 10 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c
index adabd9c..4532ba3 100644
--- a/lib/lz4hc.c
+++ b/lib/lz4hc.c
@@ -195,12 +195,6 @@ LZ4_FORCE_INLINE int LZ4HC_InsertAndGetWiderMatch (
while ((matchIndex>=lowLimit) && (nbAttempts)) {
nbAttempts--;
- int trace = 0;
- if (nbAttempts==0) {
- trace = 1;
- DEBUGLOG(2, "reached max nb of attempts ! : %08X => %08X ",
- pattern, HASH_FUNCTION(pattern));
- }
if (matchIndex >= dictLimit) {
const BYTE* const matchPtr = base + matchIndex;
if (*(iLowLimit + longest) == *(matchPtr - delta + longest)) {
@@ -249,7 +243,6 @@ LZ4_FORCE_INLINE int LZ4HC_InsertAndGetWiderMatch (
{ U32 const nextOffset = DELTANEXTU16(chainTable, matchIndex);
matchIndex -= nextOffset;
if (1 && (nextOffset==1)) {
- if (trace) DEBUGLOG(2, "check repeat mode : %u", repeat);
/* may be a repeated pattern */
if (repeat == rep_untested) {
if ((pattern & 0xFFFF) == (pattern >> 16)) { /* is it enough ? */
@@ -261,13 +254,11 @@ LZ4_FORCE_INLINE int LZ4HC_InsertAndGetWiderMatch (
if ( (repeat == rep_confirmed) /* proven repeated pattern (1-2-4) */
&& (matchIndex >= dictLimit) ) { /* same segment only */
const BYTE* const matchPtr = base + matchIndex;
- if (trace) DEBUGLOG(2, "search direct pattern position");
if (LZ4_read32(matchPtr) == pattern) { /* good candidate */
size_t const forwardPatternLength = LZ4HC_countPattern(matchPtr+sizeof(pattern), iHighLimit, pattern) + sizeof(pattern);
const BYTE* const maxLowPtr = (lowPrefixPtr + MAX_DISTANCE >= ip) ? lowPrefixPtr : ip - MAX_DISTANCE;
size_t const backLength = LZ4HC_reverseCountPattern(matchPtr, maxLowPtr, pattern);
size_t const currentSegmentLength = backLength + forwardPatternLength;
- if (trace) DEBUGLOG(2, "good start position (match == pattern)");
if ( (currentSegmentLength >= srcPatternLength) /* current pattern segment large enough to contain full srcPatternLength */
&& (forwardPatternLength <= srcPatternLength) ) { /* haven't reached this position yet */
diff --git a/lib/lz4opt.h b/lib/lz4opt.h
index ef7b725..bd956ee 100644
--- a/lib/lz4opt.h
+++ b/lib/lz4opt.h
@@ -213,7 +213,7 @@ LZ4_FORCE_INLINE int LZ4HC_HashChain_GetAllMatches (
{
const BYTE* matchPtr;
int matchLength = LZ4HC_FindLongerMatch(ctx, ip, iHighLimit, (int)best_mlen, &matchPtr, ctx->searchNum);
- if (matchLength < MINMATCH) return 0;
+ if ((size_t)matchLength <= best_mlen) return 0;
assert(matches != NULL);
matches[0].len = matchLength;
matches[0].off = (int)(ip-matchPtr);
@@ -327,6 +327,7 @@ static int LZ4HC_compress_optimal (
//nb_matches = LZ4HC_BinTree_GetAllMatches(ctx, curPtr, matchlimit, MINMATCH-1, matches, fullUpdate);
nb_matches = LZ4HC_HashChain_GetAllMatches(ctx, curPtr, matchlimit, MINMATCH-1, matches, fullUpdate);
+ //nb_matches = LZ4HC_HashChain_GetAllMatches(ctx, curPtr, matchlimit, last_match_pos - cur + 1, matches, fullUpdate); /* only works if last_match_pos is really the last match pos */
if ((nb_matches > 0) && (size_t)matches[nb_matches-1].len > sufficient_len) {
/* immediate encoding */
best_mlen = matches[nb_matches-1].len;