mirror of
https://github.com/facebook/zstd.git
synced 2025-10-18 00:03:50 -04:00
setParameter : no side-effect on setting a compression parameter
last such side-effect was modifying cctx->loadedDictEnd on setting forceWindow. It is no a useless operation, so it's removed. No side-effect left when setting a compression parameter.
This commit is contained in:
parent
6fc63f521f
commit
5e1f34b7e4
@ -270,9 +270,8 @@ size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned v
|
|||||||
return ZSTD_CCtxParam_setParameter(&cctx->requestedParams, param, value);
|
return ZSTD_CCtxParam_setParameter(&cctx->requestedParams, param, value);
|
||||||
|
|
||||||
case ZSTD_p_forceMaxWindow : /* Force back-references to remain < windowSize,
|
case ZSTD_p_forceMaxWindow : /* Force back-references to remain < windowSize,
|
||||||
* even when referencing into Dictionary content
|
* even when referencing into Dictionary content.
|
||||||
* default : 0 when using a CDict, 1 when using a Prefix */
|
* default : 0 when using a CDict, 1 when using a Prefix */
|
||||||
cctx->loadedDictEnd = 0; /* ? */
|
|
||||||
return ZSTD_CCtxParam_setParameter(&cctx->requestedParams, param, value);
|
return ZSTD_CCtxParam_setParameter(&cctx->requestedParams, param, value);
|
||||||
|
|
||||||
case ZSTD_p_nbThreads:
|
case ZSTD_p_nbThreads:
|
||||||
@ -461,13 +460,9 @@ size_t ZSTD_CCtxParam_setParameter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** ZSTD_CCtx_setParametersUsingCCtxParams() :
|
||||||
* This function should be updated whenever ZSTD_CCtx_params is updated.
|
* just applies `params` into `cctx`
|
||||||
* Parameters are copied manually before the dictionary is loaded.
|
* no action is performed, parameters are merely stored.
|
||||||
* The multithreading parameters jobSize and overlapSizeLog are set only if
|
|
||||||
* nbThreads > 1.
|
|
||||||
*
|
|
||||||
* pledgedSrcSize is considered unknown
|
|
||||||
*/
|
*/
|
||||||
size_t ZSTD_CCtx_setParametersUsingCCtxParams(
|
size_t ZSTD_CCtx_setParametersUsingCCtxParams(
|
||||||
ZSTD_CCtx* cctx, const ZSTD_CCtx_params* params)
|
ZSTD_CCtx* cctx, const ZSTD_CCtx_params* params)
|
||||||
@ -475,31 +470,8 @@ size_t ZSTD_CCtx_setParametersUsingCCtxParams(
|
|||||||
if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
|
if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
|
||||||
if (cctx->cdict) return ERROR(stage_wrong);
|
if (cctx->cdict) return ERROR(stage_wrong);
|
||||||
|
|
||||||
#if 1
|
|
||||||
cctx->requestedParams = *params;
|
cctx->requestedParams = *params;
|
||||||
#else
|
|
||||||
/* Assume the compression and frame parameters are validated */
|
|
||||||
cctx->requestedParams.cParams = params->cParams;
|
|
||||||
cctx->requestedParams.fParams = params->fParams;
|
|
||||||
cctx->requestedParams.compressionLevel = params->compressionLevel;
|
|
||||||
|
|
||||||
/* Set force window explicitly since it sets cctx->loadedDictEnd */
|
|
||||||
CHECK_F( ZSTD_CCtx_setParameter(
|
|
||||||
cctx, ZSTD_p_forceMaxWindow, params->forceWindow) );
|
|
||||||
|
|
||||||
/* Set multithreading parameters explicitly */
|
|
||||||
CHECK_F( ZSTD_CCtx_setParameter(cctx, ZSTD_p_nbThreads, params->nbThreads) );
|
|
||||||
if (params->nbThreads > 1) {
|
|
||||||
CHECK_F( ZSTD_CCtx_setParameter(cctx, ZSTD_p_jobSize, params->jobSize) );
|
|
||||||
CHECK_F( ZSTD_CCtx_setParameter(
|
|
||||||
cctx, ZSTD_p_overlapSizeLog, params->overlapSizeLog) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copy long distance matching parameters */
|
|
||||||
cctx->requestedParams.ldmParams = params->ldmParams;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* customMem is used only for create/free params and can be ignored */
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2097,7 +2069,6 @@ size_t ZSTD_compressBegin_advanced_internal(
|
|||||||
unsigned long long pledgedSrcSize)
|
unsigned long long pledgedSrcSize)
|
||||||
{
|
{
|
||||||
DEBUGLOG(4, "ZSTD_compressBegin_advanced_internal");
|
DEBUGLOG(4, "ZSTD_compressBegin_advanced_internal");
|
||||||
DEBUGLOG(4, "contentSizeFlag : %u", params.fParams.contentSizeFlag);
|
|
||||||
/* compression parameters verification and optimization */
|
/* compression parameters verification and optimization */
|
||||||
CHECK_F( ZSTD_checkCParams(params.cParams) );
|
CHECK_F( ZSTD_checkCParams(params.cParams) );
|
||||||
return ZSTD_compressBegin_internal(cctx, dict, dictSize, dictMode, NULL,
|
return ZSTD_compressBegin_internal(cctx, dict, dictSize, dictMode, NULL,
|
||||||
|
@ -359,7 +359,7 @@ void ZSTDMT_compressChunk(void* jobDescription)
|
|||||||
assert(job->firstChunk); /* should only happen for first segment */
|
assert(job->firstChunk); /* should only happen for first segment */
|
||||||
if (ZSTD_isError(initError)) { job->cSize = initError; goto _endJob; }
|
if (ZSTD_isError(initError)) { job->cSize = initError; goto _endJob; }
|
||||||
} else { /* srcStart points at reloaded section */
|
} else { /* srcStart points at reloaded section */
|
||||||
ZSTD_CCtx_params jobParams = job->params;
|
ZSTD_CCtx_params jobParams = job->params; /* do not modify job->params ! copy it, modify the copy */
|
||||||
size_t const forceWindowError = ZSTD_CCtxParam_setParameter(&jobParams, ZSTD_p_forceMaxWindow, !job->firstChunk);
|
size_t const forceWindowError = ZSTD_CCtxParam_setParameter(&jobParams, ZSTD_p_forceMaxWindow, !job->firstChunk);
|
||||||
U64 const pledgedSrcSize = job->firstChunk ? job->fullFrameSize : ZSTD_CONTENTSIZE_UNKNOWN;
|
U64 const pledgedSrcSize = job->firstChunk ? job->fullFrameSize : ZSTD_CONTENTSIZE_UNKNOWN;
|
||||||
/* load dictionary in "content-only" mode (no header analysis) */
|
/* load dictionary in "content-only" mode (no header analysis) */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user