diff options
author | Yann Collet <cyan@fb.com> | 2017-11-07 19:33:40 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2017-11-07 19:33:40 (GMT) |
commit | 71fd08c17daa3deee0c2c3c64c8f009729055bad (patch) | |
tree | 0f218b70c9d9f3d82698a683c9e2db8822690663 | |
parent | c49f66f2adf27af499cf7efacbad656bf30d671a (diff) | |
download | lz4-71fd08c17daa3deee0c2c3c64c8f009729055bad.zip lz4-71fd08c17daa3deee0c2c3c64c8f009729055bad.tar.gz lz4-71fd08c17daa3deee0c2c3c64c8f009729055bad.tar.bz2 |
removed legacy version of LZ4HC_InsertAndFindBestMatch()
-rw-r--r-- | lib/lz4hc.c | 54 |
1 files changed, 1 insertions, 53 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c index 93017f1..3498391 100644 --- a/lib/lz4hc.c +++ b/lib/lz4hc.c @@ -275,7 +275,7 @@ LZ4_FORCE_INLINE int LZ4HC_InsertAndGetWiderMatch ( } else { repeat = rep_not; } } - if ( (repeat == rep_confirmed) /* proven repeated pattern (1-2-4) */ + if ( (repeat == rep_confirmed) && (matchIndex >= dictLimit) ) { /* same segment only */ const BYTE* const matchPtr = base + matchIndex; if (LZ4_read32(matchPtr) == pattern) { /* good candidate */ @@ -296,7 +296,6 @@ LZ4_FORCE_INLINE int LZ4HC_InsertAndGetWiderMatch ( return longest; } -#if 1 LZ4_FORCE_INLINE int LZ4HC_InsertAndFindBestMatch(LZ4HC_CCtx_internal* const hc4, /* Index table will be updated */ const BYTE* const ip, const BYTE* const iLimit, @@ -307,57 +306,6 @@ int LZ4HC_InsertAndFindBestMatch(LZ4HC_CCtx_internal* const hc4, /* Index tabl return LZ4HC_InsertAndGetWiderMatch(hc4, ip, ip, iLimit, MINMATCH-1, matchpos, &uselessPtr, maxNbAttempts); } -#else - -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) -{ - U16* const chainTable = hc4->chainTable; - U32* const HashTable = hc4->hashTable; - const BYTE* const base = hc4->base; - const BYTE* const dictBase = hc4->dictBase; - const U32 dictLimit = hc4->dictLimit; - const U32 lowLimit = (hc4->lowLimit + 64 KB > (U32)(ip-base)) ? hc4->lowLimit : (U32)(ip - base) - (64 KB - 1); - U32 matchIndex; - int nbAttempts = maxNbAttempts; - size_t ml = 0; - - /* HC4 match finder */ - LZ4HC_Insert(hc4, ip); - matchIndex = HashTable[LZ4HC_hashPtr(ip)]; - - while ((matchIndex>=lowLimit) && (nbAttempts)) { - nbAttempts--; - if (matchIndex >= dictLimit) { - const BYTE* const match = base + matchIndex; - if ( (*(match+ml) == *(ip+ml)) /* can be longer */ - && (LZ4_read32(match) == LZ4_read32(ip)) ) - { - size_t const mlt = LZ4_count(ip+MINMATCH, match+MINMATCH, iLimit) + MINMATCH; - if (mlt > ml) { ml = mlt; *matchpos = match; } - } - } else { - const BYTE* const match = dictBase + matchIndex; - if (LZ4_read32(match) == LZ4_read32(ip)) { - size_t mlt; - const BYTE* vLimit = ip + (dictLimit - matchIndex); - if (vLimit > iLimit) vLimit = iLimit; - mlt = LZ4_count(ip+MINMATCH, match+MINMATCH, vLimit) + MINMATCH; - if ((ip+mlt == vLimit) && (vLimit < iLimit)) - mlt += LZ4_count(ip+mlt, base+dictLimit, iLimit); - if (mlt > ml) { ml = mlt; *matchpos = base + matchIndex; } /* virtual matchpos */ - } - } - matchIndex -= DELTANEXTU16(chainTable, matchIndex); - } - - return (int)ml; -} -#endif - typedef enum { |