diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lz4hc.c | 2 | ||||
-rw-r--r-- | lib/lz4opt.h | 31 |
2 files changed, 12 insertions, 21 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c index b8d8a78..60690a0 100644 --- a/lib/lz4hc.c +++ b/lib/lz4hc.c @@ -304,7 +304,7 @@ int LZ4HC_InsertAndFindBestMatch(LZ4HC_CCtx_internal* const hc4, /* Index tabl const BYTE* uselessPtr = ip; /* note : LZ4HC_InsertAndGetWiderMatch() is able to modify the starting position of a match (*startpos), * but this won't be the case here, as we define iLowLimit==ip, - * so LZ4HC_InsertAndGetWiderMatch() will not be allowed to search past ip */ + * so LZ4HC_InsertAndGetWiderMatch() won't be allowed to search past ip */ return LZ4HC_InsertAndGetWiderMatch(hc4, ip, ip, iLimit, MINMATCH-1, matchpos, &uselessPtr, maxNbAttempts); } diff --git a/lib/lz4opt.h b/lib/lz4opt.h index 03ab825..6db8586 100644 --- a/lib/lz4opt.h +++ b/lib/lz4opt.h @@ -70,32 +70,23 @@ LZ4_FORCE_INLINE int LZ4HC_sequencePrice(int litlen, int mlen) /*-************************************* * Match finder ***************************************/ - -LZ4_FORCE_INLINE -int LZ4HC_FindLongerMatch(LZ4HC_CCtx_internal* const ctx, /* Index table will be updated */ - const BYTE* const ip, const BYTE* const iHighLimit, - int longest, - const BYTE** matchpos, - const int maxNbAttempts) -{ - const BYTE* uselessPtr = ip; - return LZ4HC_InsertAndGetWiderMatch(ctx, ip, ip, iHighLimit, longest, matchpos, &uselessPtr, maxNbAttempts); -} - typedef struct { int off; int len; } LZ4HC_match_t; LZ4_FORCE_INLINE -LZ4HC_match_t LZ4HC_HashChain_GetAllMatches (LZ4HC_CCtx_internal* const ctx, - const BYTE* const ip, const BYTE* const iHighLimit, - size_t best_mlen, int nbSearches) +LZ4HC_match_t LZ4HC_FindLongerMatch(LZ4HC_CCtx_internal* const ctx, + const BYTE* ip, const BYTE* const iHighLimit, + int minLen, int nbSearches) { LZ4HC_match_t match = { 0 , 0 }; const BYTE* matchPtr = NULL; - int matchLength = LZ4HC_FindLongerMatch(ctx, ip, iHighLimit, (int)best_mlen, &matchPtr, nbSearches); - if ((size_t)matchLength <= best_mlen) return match; + /* note : LZ4HC_InsertAndGetWiderMatch() is able to modify the starting position of a match (*startpos), + * but this won't be the case here, as we define iLowLimit==ip, + * so LZ4HC_InsertAndGetWiderMatch() won't be allowed to search past ip */ + int const matchLength = LZ4HC_InsertAndGetWiderMatch(ctx, ip, ip, iHighLimit, minLen, &matchPtr, &ip, nbSearches); + if (matchLength <= minLen) return match; match.len = matchLength; match.off = (int)(ip-matchPtr); return match; @@ -135,7 +126,7 @@ static int LZ4HC_compress_optimal ( int best_mlen, best_off; int cur, last_match_pos = 0; - LZ4HC_match_t const firstMatch = LZ4HC_HashChain_GetAllMatches(ctx, ip, matchlimit, MINMATCH-1, nbSearches); + LZ4HC_match_t const firstMatch = LZ4HC_FindLongerMatch(ctx, ip, matchlimit, MINMATCH-1, nbSearches); if (firstMatch.len==0) { ip++; continue; } if ((size_t)firstMatch.len > sufficient_len) { @@ -199,10 +190,10 @@ static int LZ4HC_compress_optimal ( DEBUGLOG(7, "search at rPos:%u", cur); if (fullUpdate) - newMatch = LZ4HC_HashChain_GetAllMatches(ctx, curPtr, matchlimit, MINMATCH-1, nbSearches); + newMatch = LZ4HC_FindLongerMatch(ctx, curPtr, matchlimit, MINMATCH-1, nbSearches); else /* only test matches of minimum length; slightly faster, but misses a few bytes */ - newMatch = LZ4HC_HashChain_GetAllMatches(ctx, curPtr, matchlimit, last_match_pos - cur, nbSearches); + newMatch = LZ4HC_FindLongerMatch(ctx, curPtr, matchlimit, last_match_pos - cur, nbSearches); if (!newMatch.len) continue; if ( ((size_t)newMatch.len > sufficient_len) |