Add a function for LDM enable check
This commit is contained in:
@@ -202,6 +202,14 @@ size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs)
|
|||||||
/* private API call, for dictBuilder only */
|
/* private API call, for dictBuilder only */
|
||||||
const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx) { return &(ctx->seqStore); }
|
const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx) { return &(ctx->seqStore); }
|
||||||
|
|
||||||
|
/* Returns 1 if compression parameters are such that we should
|
||||||
|
* enable long distance matching (wlog >= 27, strategy >= btopt).
|
||||||
|
* Returns 0 otherwise.
|
||||||
|
*/
|
||||||
|
static U32 ZSTD_CParams_shouldEnableLdm(const ZSTD_compressionParameters* const cParams) {
|
||||||
|
return cParams->strategy >= ZSTD_btopt && cParams->windowLog >= 27;
|
||||||
|
}
|
||||||
|
|
||||||
static ZSTD_CCtx_params ZSTD_makeCCtxParamsFromCParams(
|
static ZSTD_CCtx_params ZSTD_makeCCtxParamsFromCParams(
|
||||||
ZSTD_compressionParameters cParams)
|
ZSTD_compressionParameters cParams)
|
||||||
{
|
{
|
||||||
@@ -210,7 +218,7 @@ static ZSTD_CCtx_params ZSTD_makeCCtxParamsFromCParams(
|
|||||||
ZSTD_CCtxParams_init(&cctxParams, ZSTD_CLEVEL_DEFAULT);
|
ZSTD_CCtxParams_init(&cctxParams, ZSTD_CLEVEL_DEFAULT);
|
||||||
cctxParams.cParams = cParams;
|
cctxParams.cParams = cParams;
|
||||||
|
|
||||||
if (cParams.strategy >= ZSTD_btopt && cParams.windowLog >= 27 && cctxParams.nbWorkers == 0) {
|
if (ZSTD_CParams_shouldEnableLdm(&cParams)) {
|
||||||
DEBUGLOG(4, "ZSTD_makeCCtxParamsFromCParams(): Including LDM into cctx params");
|
DEBUGLOG(4, "ZSTD_makeCCtxParamsFromCParams(): Including LDM into cctx params");
|
||||||
cctxParams.ldmParams.enableLdm = 1;
|
cctxParams.ldmParams.enableLdm = 1;
|
||||||
/* LDM is enabled by default for optimal parser and window size >= 128MB */
|
/* LDM is enabled by default for optimal parser and window size >= 128MB */
|
||||||
@@ -4188,7 +4196,7 @@ size_t ZSTD_compressStream2( ZSTD_CCtx* cctx,
|
|||||||
dictSize, mode);
|
dictSize, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.cParams.strategy >= ZSTD_btopt && params.cParams.windowLog >= 27) {
|
if (ZSTD_CParams_shouldEnableLdm(¶ms.cParams)) {
|
||||||
/* Enable LDM by default for optimal parser and window size >= 128MB */
|
/* Enable LDM by default for optimal parser and window size >= 128MB */
|
||||||
DEBUGLOG(4, "LDM enabled by default (window size >= 128MB, strategy >= btopt)");
|
DEBUGLOG(4, "LDM enabled by default (window size >= 128MB, strategy >= btopt)");
|
||||||
params.ldmParams.enableLdm = 1;
|
params.ldmParams.enableLdm = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user