return 0;
}
-static int LZ4HC_getSearchNum(int compressionLevel)
-{
- assert(compressionLevel >= 1);
- assert(compressionLevel <= LZ4HC_CLEVEL_MAX);
- switch (compressionLevel) {
- default: return 1 << (compressionLevel-1);
- case 10: return 1 << 12;
- case 11: return 512;
- case 12: return 1<<13;
- }
-}
static int LZ4HC_compress_generic (
LZ4HC_CCtx_internal* const ctx,
if (limit == limitedDestSize) cLevel = 10;
switch (cLevel) {
case 10:
- return LZ4HC_compress_hashChain(ctx, src, dst, srcSizePtr, dstCapacity, 1 << 12, limit);
+ return LZ4HC_compress_hashChain(ctx, src, dst, srcSizePtr, dstCapacity, 1<<12, limit);
case 11:
- ctx->searchNum = LZ4HC_getSearchNum(cLevel);
- return LZ4HC_compress_optimal(ctx, src, dst, *srcSizePtr, dstCapacity, limit, 128, 0);
+ return LZ4HC_compress_optimal(ctx, src, dst, *srcSizePtr, dstCapacity, limit, 512, 128, 0);
default:
cLevel = 12;
/* fall-through */
case 12:
- ctx->searchNum = LZ4HC_getSearchNum(cLevel);
- return LZ4HC_compress_optimal(ctx, src, dst, *srcSizePtr, dstCapacity, limit, LZ4_OPT_NUM, 1);
+ return LZ4HC_compress_optimal(ctx, src, dst, *srcSizePtr, dstCapacity, limit, 1<<13, LZ4_OPT_NUM, 1);
}
}
return LZ4HC_compress_hashChain(ctx, src, dst, srcSizePtr, dstCapacity, 1 << (cLevel-1), limit); /* levels 1-9 */
LZ4_streamHCPtr->internal_donotuse.base = NULL;
if (compressionLevel > LZ4HC_CLEVEL_MAX) compressionLevel = LZ4HC_CLEVEL_MAX; /* cap compression level */
LZ4_streamHCPtr->internal_donotuse.compressionLevel = compressionLevel;
- LZ4_streamHCPtr->internal_donotuse.searchNum = LZ4HC_getSearchNum(compressionLevel);
}
void LZ4_setCompressionLevel(LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel)
uint32_t dictLimit; /* below that point, need extDict */
uint32_t lowLimit; /* below that point, no more dict */
uint32_t nextToUpdate; /* index from which to continue dictionary update */
- uint32_t searchNum; /* only for optimal parser */
- uint32_t compressionLevel;
+ int compressionLevel;
} LZ4HC_CCtx_internal;
#else
unsigned int dictLimit; /* below that point, need extDict */
unsigned int lowLimit; /* below that point, no more dict */
unsigned int nextToUpdate; /* index from which to continue dictionary update */
- unsigned int searchNum; /* only for optimal parser */
int compressionLevel;
} LZ4HC_CCtx_internal;
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)
+ size_t best_mlen, int nbSearches)
{
LZ4HC_match_t match = {0 , 0};
const BYTE* matchPtr = NULL;
- int matchLength = LZ4HC_FindLongerMatch(ctx, ip, iHighLimit, (int)best_mlen, &matchPtr, ctx->searchNum);
+ int matchLength = LZ4HC_FindLongerMatch(ctx, ip, iHighLimit, (int)best_mlen, &matchPtr, nbSearches);
if ((size_t)matchLength <= best_mlen) return match;
match.len = matchLength;
match.off = (int)(ip-matchPtr);
int inputSize,
int dstCapacity,
limitedOutput_directive limit,
+ int const nbSearches,
size_t sufficient_len,
- const int fullUpdate
+ int const fullUpdate
)
{
LZ4HC_optimal_t opt[LZ4_OPT_NUM + 3]; /* this uses a bit too much stack memory to my taste ... */
int best_mlen, best_off;
int cur, last_match_pos = 0;
- LZ4HC_match_t const firstMatch = LZ4HC_HashChain_GetAllMatches(ctx, ip, matchlimit, MINMATCH-1);
+ LZ4HC_match_t const firstMatch = LZ4HC_HashChain_GetAllMatches(ctx, ip, matchlimit, MINMATCH-1, nbSearches);
if (firstMatch.len==0) { ip++; continue; }
if ((size_t)firstMatch.len > sufficient_len) {
DEBUGLOG(7, "search at rPos:%u", cur);
if (fullUpdate)
- newMatch = LZ4HC_HashChain_GetAllMatches(ctx, curPtr, matchlimit, MINMATCH-1);
+ newMatch = LZ4HC_HashChain_GetAllMatches(ctx, curPtr, matchlimit, MINMATCH-1, nbSearches);
else
- newMatch = LZ4HC_HashChain_GetAllMatches(ctx, curPtr, matchlimit, last_match_pos - cur); /* only test matches of a minimum length; slightly faster, but misses a few bytes */
+ /* 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);
if (!newMatch.len) continue;
if ( ((size_t)newMatch.len > sufficient_len)