Removed if (matchIndex >= current) return 0; as recommended by @inikep
This commit is contained in:
+9
-12
@@ -172,8 +172,7 @@ MEM_STATIC void ZSTD_updatePrice(seqStore_t* seqStorePtr, U32 litLength, const B
|
||||
/*-*************************************
|
||||
* Binary Tree search
|
||||
***************************************/
|
||||
FORCE_INLINE /* inlining is important to hardwire a hot branch (template emulation) */
|
||||
U32 ZSTD_insertBtAndGetAllMatches (
|
||||
static U32 ZSTD_insertBtAndGetAllMatches (
|
||||
ZSTD_CCtx* zc,
|
||||
const BYTE* const ip, const BYTE* const iend,
|
||||
U32 nbCompares, const U32 mls,
|
||||
@@ -201,7 +200,6 @@ U32 ZSTD_insertBtAndGetAllMatches (
|
||||
U32 dummy32; /* to be nullified at the end */
|
||||
U32 mnum = 0;
|
||||
|
||||
if (matchIndex >= current) return 0;
|
||||
bestLength = MINMATCH-1;
|
||||
hashTable[h] = current; /* Update Hash Table */
|
||||
|
||||
@@ -257,8 +255,7 @@ U32 ZSTD_insertBtAndGetAllMatches (
|
||||
|
||||
|
||||
/** Tree updater, providing best match */
|
||||
FORCE_INLINE /* inlining is important to hardwire a hot branch (template emulation) */
|
||||
U32 ZSTD_BtGetAllMatches (
|
||||
static U32 ZSTD_BtGetAllMatches (
|
||||
ZSTD_CCtx* zc,
|
||||
const BYTE* const ip, const BYTE* const iLimit,
|
||||
const U32 maxNbAttempts, const U32 mls, ZSTD_match_t* matches, U32 minml)
|
||||
@@ -285,8 +282,7 @@ static U32 ZSTD_BtGetAllMatches_selectMLS (
|
||||
}
|
||||
|
||||
/** Tree updater, providing best match */
|
||||
FORCE_INLINE /* inlining is important to hardwire a hot branch (template emulation) */
|
||||
U32 ZSTD_BtGetAllMatches_extDict (
|
||||
static U32 ZSTD_BtGetAllMatches_extDict (
|
||||
ZSTD_CCtx* zc,
|
||||
const BYTE* const ip, const BYTE* const iLimit,
|
||||
const U32 maxNbAttempts, const U32 mls, ZSTD_match_t* matches, U32 minml)
|
||||
@@ -342,7 +338,6 @@ U32 ZSTD_HcGetAllMatches_generic (
|
||||
|
||||
/* HC4 match finder */
|
||||
matchIndex = ZSTD_insertAndFindFirstIndex (zc, ip, mls);
|
||||
if (matchIndex >= current) return 0;
|
||||
|
||||
while ((matchIndex>lowLimit) && (nbAttempts)) {
|
||||
size_t currentMl=0;
|
||||
@@ -746,9 +741,10 @@ _storeSequence: /* cur, last_pos, best_mlen, best_off have to be set */
|
||||
ZSTD_updatePrice(seqStorePtr, 0, anchor, 0, best_mlen);
|
||||
ZSTD_storeSeq(seqStorePtr, 0, anchor, 0, best_mlen);
|
||||
anchor += best_mlen+MINMATCH;
|
||||
ip = anchor;
|
||||
continue; /* faster when present ... (?) */
|
||||
} }
|
||||
}
|
||||
if (anchor > ip) ip = anchor;
|
||||
}
|
||||
|
||||
{ /* Last Literals */
|
||||
size_t lastLLSize = iend - anchor;
|
||||
@@ -1112,11 +1108,12 @@ _storeSequence: // cur, last_pos, best_mlen, best_off have to be set
|
||||
ZSTD_updatePrice(seqStorePtr, 0, anchor, 0, mlen-MINMATCH);
|
||||
ZSTD_storeSeq(seqStorePtr, 0, anchor, 0, mlen-MINMATCH);
|
||||
anchor += mlen;
|
||||
ip = anchor;
|
||||
continue; /* faster when present ... (?) */
|
||||
}
|
||||
break;
|
||||
} }
|
||||
}
|
||||
if (anchor > ip) ip = anchor;
|
||||
}
|
||||
|
||||
{ /* Last Literals */
|
||||
size_t lastLLSize = iend - anchor;
|
||||
|
||||
+3
-1
@@ -91,6 +91,7 @@ static U32 g_testTime = 0;
|
||||
/*********************************************************
|
||||
* Fuzzer functions
|
||||
*********************************************************/
|
||||
#define MIN(a,b) ((a)<(b)?(a):(b))
|
||||
#define MAX(a,b) ((a)>(b)?(a):(b))
|
||||
|
||||
static U32 FUZ_GetMilliStart(void)
|
||||
@@ -452,7 +453,8 @@ int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compressibilit
|
||||
crcOrig = XXH64(sampleBuffer, sampleSize, 0);
|
||||
|
||||
/* compression test */
|
||||
cLevelMod = MAX(1, 38 - (int)(MAX(9, sampleSizeLog) * 2)); /* high levels only for small samples, for manageable speed */
|
||||
//cLevelMod = MAX(1, 38 - (int)(MAX(9, sampleSizeLog) * 2)); /* high levels only for small samples, for manageable speed */
|
||||
cLevelMod = MIN( ZSTD_maxCLevel(), (U32)MAX(1, 55 - 3*(int)sampleSizeLog) ); /* high levels only for small samples, for manageable speed */
|
||||
cLevel = (FUZ_rand(&lseed) % cLevelMod) +1;
|
||||
cSize = ZSTD_compressCCtx(ctx, cBuffer, cBufferSize, sampleBuffer, sampleSize, cLevel);
|
||||
CHECK(ZSTD_isError(cSize), "ZSTD_compressCCtx failed");
|
||||
|
||||
Reference in New Issue
Block a user