insertAndFindBestMatch defers to insertAndGetWiderMatch

This commit is contained in:
Yann Collet 2017-10-08 23:40:21 -07:00
parent 87968517f9
commit f1fa91d6fc

View File

@ -116,7 +116,7 @@ LZ4_FORCE_INLINE void LZ4HC_Insert (LZ4HC_CCtx_internal* hc4, const BYTE* ip)
hc4->nextToUpdate = target; hc4->nextToUpdate = target;
} }
#if 0
LZ4_FORCE_INLINE int LZ4HC_InsertAndFindBestMatch (LZ4HC_CCtx_internal* const hc4, /* Index table will be updated */ LZ4_FORCE_INLINE int LZ4HC_InsertAndFindBestMatch (LZ4HC_CCtx_internal* const hc4, /* Index table will be updated */
const BYTE* const ip, const BYTE* const iLimit, const BYTE* const ip, const BYTE* const iLimit,
const BYTE** matchpos, const BYTE** matchpos,
@ -163,7 +163,7 @@ LZ4_FORCE_INLINE int LZ4HC_InsertAndFindBestMatch (LZ4HC_CCtx_internal* const hc
return (int)ml; return (int)ml;
} }
#endif
LZ4_FORCE_INLINE int LZ4HC_InsertAndGetWiderMatch ( LZ4_FORCE_INLINE int LZ4HC_InsertAndGetWiderMatch (
LZ4HC_CCtx_internal* hc4, LZ4HC_CCtx_internal* hc4,
@ -234,6 +234,16 @@ LZ4_FORCE_INLINE int LZ4HC_InsertAndGetWiderMatch (
return longest; return longest;
} }
LZ4_FORCE_INLINE
int LZ4HC_InsertAndFindBestMatch(LZ4HC_CCtx_internal* const hc4, /* Index table will be updated */
const BYTE* const ip, const BYTE* const iLimit,
const BYTE** matchpos,
const int maxNbAttempts)
{
const BYTE* uselessPtr = ip;
return LZ4HC_InsertAndGetWiderMatch(hc4, ip, ip, iLimit, MINMATCH-1, matchpos, &uselessPtr, maxNbAttempts);
}
typedef enum { typedef enum {
noLimit = 0, noLimit = 0,
@ -353,7 +363,7 @@ static int LZ4HC_compress_hashChain (
/* Main Loop */ /* Main Loop */
while (ip < mflimit) { while (ip < mflimit) {
ml = LZ4HC_InsertAndFindBestMatch (ctx, ip, matchlimit, (&ref), maxNbAttempts); ml = LZ4HC_InsertAndFindBestMatch (ctx, ip, matchlimit, (&ref), maxNbAttempts);
if (!ml) { ip++; continue; } if (ml<MINMATCH) { ip++; continue; }
/* saved, in case we would skip too much */ /* saved, in case we would skip too much */
start0 = ip; start0 = ip;