1
0
mirror of https://github.com/facebook/zstd.git synced 2025-07-30 22:23:13 +03:00

codemod: ZSTD_paramSwitch_e -> ZSTD_ParamSwitch_e

This commit is contained in:
Yann Collet
2024-12-10 16:54:53 -08:00
parent 13b9296d79
commit 56cfb7816a
12 changed files with 71 additions and 61 deletions

View File

@ -1025,7 +1025,7 @@ int main (int argc, const char** argv)
unsigned nbBlocks = 0; /* determine nbBlocks automatically, from source and blockSize */ unsigned nbBlocks = 0; /* determine nbBlocks automatically, from source and blockSize */
ZSTD_dictContentType_e dictContentType = ZSTD_dct_auto; ZSTD_dictContentType_e dictContentType = ZSTD_dct_auto;
ZSTD_dictAttachPref_e dictAttachPref = ZSTD_dictDefaultAttach; ZSTD_dictAttachPref_e dictAttachPref = ZSTD_dictDefaultAttach;
ZSTD_paramSwitch_e prefetchCDictTables = ZSTD_ps_auto; ZSTD_ParamSwitch_e prefetchCDictTables = ZSTD_ps_auto;
metricAggregatePref_e metricAggregatePref = fastest; metricAggregatePref_e metricAggregatePref = fastest;
for (int argNb = 1; argNb < argc ; argNb++) { for (int argNb = 1; argNb < argc ; argNb++) {

View File

@ -1196,7 +1196,7 @@ size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
ZSTD_ps_auto = 0, </b>/* Let the library automatically determine whether the feature shall be enabled */<b> ZSTD_ps_auto = 0, </b>/* Let the library automatically determine whether the feature shall be enabled */<b>
ZSTD_ps_enable = 1, </b>/* Force-enable the feature */<b> ZSTD_ps_enable = 1, </b>/* Force-enable the feature */<b>
ZSTD_ps_disable = 2 </b>/* Do not use the feature */<b> ZSTD_ps_disable = 2 </b>/* Do not use the feature */<b>
} ZSTD_paramSwitch_e; } ZSTD_ParamSwitch_e;
</b></pre><BR> </b></pre><BR>
<a name="Chapter15"></a><h2>Frame header and size functions</h2><pre></pre> <a name="Chapter15"></a><h2>Frame header and size functions</h2><pre></pre>

View File

@ -87,7 +87,7 @@ struct ZSTD_CDict_s {
ZSTD_customMem customMem; ZSTD_customMem customMem;
U32 dictID; U32 dictID;
int compressionLevel; /* 0 indicates that advanced API was used to select CDict params */ int compressionLevel; /* 0 indicates that advanced API was used to select CDict params */
ZSTD_paramSwitch_e useRowMatchFinder; /* Indicates whether the CDict was created with params that would use ZSTD_ParamSwitch_e useRowMatchFinder; /* Indicates whether the CDict was created with params that would use
* row-based matchfinder. Unless the cdict is reloaded, we will use * row-based matchfinder. Unless the cdict is reloaded, we will use
* the same greedy/lazy matchfinder at compression time. * the same greedy/lazy matchfinder at compression time.
*/ */
@ -228,13 +228,13 @@ static int ZSTD_rowMatchFinderSupported(const ZSTD_strategy strategy) {
/* Returns true if the strategy and useRowMatchFinder mode indicate that we will use the row based matchfinder /* Returns true if the strategy and useRowMatchFinder mode indicate that we will use the row based matchfinder
* for this compression. * for this compression.
*/ */
static int ZSTD_rowMatchFinderUsed(const ZSTD_strategy strategy, const ZSTD_paramSwitch_e mode) { static int ZSTD_rowMatchFinderUsed(const ZSTD_strategy strategy, const ZSTD_ParamSwitch_e mode) {
assert(mode != ZSTD_ps_auto); assert(mode != ZSTD_ps_auto);
return ZSTD_rowMatchFinderSupported(strategy) && (mode == ZSTD_ps_enable); return ZSTD_rowMatchFinderSupported(strategy) && (mode == ZSTD_ps_enable);
} }
/* Returns row matchfinder usage given an initial mode and cParams */ /* Returns row matchfinder usage given an initial mode and cParams */
static ZSTD_paramSwitch_e ZSTD_resolveRowMatchFinderMode(ZSTD_paramSwitch_e mode, static ZSTD_ParamSwitch_e ZSTD_resolveRowMatchFinderMode(ZSTD_ParamSwitch_e mode,
const ZSTD_compressionParameters* const cParams) { const ZSTD_compressionParameters* const cParams) {
#if defined(ZSTD_ARCH_X86_SSE2) || defined(ZSTD_ARCH_ARM_NEON) #if defined(ZSTD_ARCH_X86_SSE2) || defined(ZSTD_ARCH_ARM_NEON)
int const kHasSIMD128 = 1; int const kHasSIMD128 = 1;
@ -253,7 +253,7 @@ static ZSTD_paramSwitch_e ZSTD_resolveRowMatchFinderMode(ZSTD_paramSwitch_e mode
} }
/* Returns block splitter usage (generally speaking, when using slower/stronger compression modes) */ /* Returns block splitter usage (generally speaking, when using slower/stronger compression modes) */
static ZSTD_paramSwitch_e ZSTD_resolveBlockSplitterMode(ZSTD_paramSwitch_e mode, static ZSTD_ParamSwitch_e ZSTD_resolveBlockSplitterMode(ZSTD_ParamSwitch_e mode,
const ZSTD_compressionParameters* const cParams) { const ZSTD_compressionParameters* const cParams) {
if (mode != ZSTD_ps_auto) return mode; if (mode != ZSTD_ps_auto) return mode;
return (cParams->strategy >= ZSTD_btopt && cParams->windowLog >= 17) ? ZSTD_ps_enable : ZSTD_ps_disable; return (cParams->strategy >= ZSTD_btopt && cParams->windowLog >= 17) ? ZSTD_ps_enable : ZSTD_ps_disable;
@ -261,7 +261,7 @@ static ZSTD_paramSwitch_e ZSTD_resolveBlockSplitterMode(ZSTD_paramSwitch_e mode,
/* Returns 1 if the arguments indicate that we should allocate a chainTable, 0 otherwise */ /* Returns 1 if the arguments indicate that we should allocate a chainTable, 0 otherwise */
static int ZSTD_allocateChainTable(const ZSTD_strategy strategy, static int ZSTD_allocateChainTable(const ZSTD_strategy strategy,
const ZSTD_paramSwitch_e useRowMatchFinder, const ZSTD_ParamSwitch_e useRowMatchFinder,
const U32 forDDSDict) { const U32 forDDSDict) {
assert(useRowMatchFinder != ZSTD_ps_auto); assert(useRowMatchFinder != ZSTD_ps_auto);
/* We always should allocate a chaintable if we are allocating a matchstate for a DDS dictionary matchstate. /* We always should allocate a chaintable if we are allocating a matchstate for a DDS dictionary matchstate.
@ -274,7 +274,7 @@ static int ZSTD_allocateChainTable(const ZSTD_strategy strategy,
* enable long distance matching (wlog >= 27, strategy >= btopt). * enable long distance matching (wlog >= 27, strategy >= btopt).
* Returns ZSTD_ps_disable otherwise. * Returns ZSTD_ps_disable otherwise.
*/ */
static ZSTD_paramSwitch_e ZSTD_resolveEnableLdm(ZSTD_paramSwitch_e mode, static ZSTD_ParamSwitch_e ZSTD_resolveEnableLdm(ZSTD_ParamSwitch_e mode,
const ZSTD_compressionParameters* const cParams) { const ZSTD_compressionParameters* const cParams) {
if (mode != ZSTD_ps_auto) return mode; if (mode != ZSTD_ps_auto) return mode;
return (cParams->strategy >= ZSTD_btopt && cParams->windowLog >= 27) ? ZSTD_ps_enable : ZSTD_ps_disable; return (cParams->strategy >= ZSTD_btopt && cParams->windowLog >= 27) ? ZSTD_ps_enable : ZSTD_ps_disable;
@ -293,7 +293,7 @@ static size_t ZSTD_resolveMaxBlockSize(size_t maxBlockSize) {
} }
} }
static ZSTD_paramSwitch_e ZSTD_resolveExternalRepcodeSearch(ZSTD_paramSwitch_e value, int cLevel) { static ZSTD_ParamSwitch_e ZSTD_resolveExternalRepcodeSearch(ZSTD_ParamSwitch_e value, int cLevel) {
if (value != ZSTD_ps_auto) return value; if (value != ZSTD_ps_auto) return value;
if (cLevel < 10) { if (cLevel < 10) {
return ZSTD_ps_disable; return ZSTD_ps_disable;
@ -865,7 +865,7 @@ size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* CCtxParams,
} }
case ZSTD_c_literalCompressionMode : { case ZSTD_c_literalCompressionMode : {
const ZSTD_paramSwitch_e lcm = (ZSTD_paramSwitch_e)value; const ZSTD_ParamSwitch_e lcm = (ZSTD_ParamSwitch_e)value;
BOUNDCHECK(ZSTD_c_literalCompressionMode, (int)lcm); BOUNDCHECK(ZSTD_c_literalCompressionMode, (int)lcm);
CCtxParams->literalCompressionMode = lcm; CCtxParams->literalCompressionMode = lcm;
return CCtxParams->literalCompressionMode; return CCtxParams->literalCompressionMode;
@ -921,7 +921,7 @@ size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* CCtxParams,
case ZSTD_c_enableLongDistanceMatching : case ZSTD_c_enableLongDistanceMatching :
BOUNDCHECK(ZSTD_c_enableLongDistanceMatching, value); BOUNDCHECK(ZSTD_c_enableLongDistanceMatching, value);
CCtxParams->ldmParams.enableLdm = (ZSTD_paramSwitch_e)value; CCtxParams->ldmParams.enableLdm = (ZSTD_ParamSwitch_e)value;
return CCtxParams->ldmParams.enableLdm; return CCtxParams->ldmParams.enableLdm;
case ZSTD_c_ldmHashLog : case ZSTD_c_ldmHashLog :
@ -984,7 +984,7 @@ size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* CCtxParams,
case ZSTD_c_splitAfterSequences: case ZSTD_c_splitAfterSequences:
BOUNDCHECK(ZSTD_c_splitAfterSequences, value); BOUNDCHECK(ZSTD_c_splitAfterSequences, value);
CCtxParams->postBlockSplitter = (ZSTD_paramSwitch_e)value; CCtxParams->postBlockSplitter = (ZSTD_ParamSwitch_e)value;
return CCtxParams->postBlockSplitter; return CCtxParams->postBlockSplitter;
case ZSTD_c_blockSplitterLevel: case ZSTD_c_blockSplitterLevel:
@ -994,7 +994,7 @@ size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* CCtxParams,
case ZSTD_c_useRowMatchFinder: case ZSTD_c_useRowMatchFinder:
BOUNDCHECK(ZSTD_c_useRowMatchFinder, value); BOUNDCHECK(ZSTD_c_useRowMatchFinder, value);
CCtxParams->useRowMatchFinder = (ZSTD_paramSwitch_e)value; CCtxParams->useRowMatchFinder = (ZSTD_ParamSwitch_e)value;
return CCtxParams->useRowMatchFinder; return CCtxParams->useRowMatchFinder;
case ZSTD_c_deterministicRefPrefix: case ZSTD_c_deterministicRefPrefix:
@ -1004,7 +1004,7 @@ size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* CCtxParams,
case ZSTD_c_prefetchCDictTables: case ZSTD_c_prefetchCDictTables:
BOUNDCHECK(ZSTD_c_prefetchCDictTables, value); BOUNDCHECK(ZSTD_c_prefetchCDictTables, value);
CCtxParams->prefetchCDictTables = (ZSTD_paramSwitch_e)value; CCtxParams->prefetchCDictTables = (ZSTD_ParamSwitch_e)value;
return CCtxParams->prefetchCDictTables; return CCtxParams->prefetchCDictTables;
case ZSTD_c_enableSeqProducerFallback: case ZSTD_c_enableSeqProducerFallback:
@ -1021,7 +1021,7 @@ size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* CCtxParams,
case ZSTD_c_searchForExternalRepcodes: case ZSTD_c_searchForExternalRepcodes:
BOUNDCHECK(ZSTD_c_searchForExternalRepcodes, value); BOUNDCHECK(ZSTD_c_searchForExternalRepcodes, value);
CCtxParams->searchForExternalRepcodes = (ZSTD_paramSwitch_e)value; CCtxParams->searchForExternalRepcodes = (ZSTD_ParamSwitch_e)value;
return CCtxParams->searchForExternalRepcodes; return CCtxParams->searchForExternalRepcodes;
default: RETURN_ERROR(parameter_unsupported, "unknown parameter"); default: RETURN_ERROR(parameter_unsupported, "unknown parameter");
@ -1482,7 +1482,7 @@ ZSTD_adjustCParams_internal(ZSTD_compressionParameters cPar,
unsigned long long srcSize, unsigned long long srcSize,
size_t dictSize, size_t dictSize,
ZSTD_cParamMode_e mode, ZSTD_cParamMode_e mode,
ZSTD_paramSwitch_e useRowMatchFinder) ZSTD_ParamSwitch_e useRowMatchFinder)
{ {
const U64 minSrcSize = 513; /* (1<<9) + 1 */ const U64 minSrcSize = 513; /* (1<<9) + 1 */
const U64 maxWindowResize = 1ULL << (ZSTD_WINDOWLOG_MAX-1); const U64 maxWindowResize = 1ULL << (ZSTD_WINDOWLOG_MAX-1);
@ -1660,7 +1660,7 @@ ZSTD_compressionParameters ZSTD_getCParamsFromCCtxParams(
static size_t static size_t
ZSTD_sizeof_matchState(const ZSTD_compressionParameters* const cParams, ZSTD_sizeof_matchState(const ZSTD_compressionParameters* const cParams,
const ZSTD_paramSwitch_e useRowMatchFinder, const ZSTD_ParamSwitch_e useRowMatchFinder,
const int enableDedicatedDictSearch, const int enableDedicatedDictSearch,
const U32 forCCtx) const U32 forCCtx)
{ {
@ -1711,7 +1711,7 @@ static size_t ZSTD_estimateCCtxSize_usingCCtxParams_internal(
const ZSTD_compressionParameters* cParams, const ZSTD_compressionParameters* cParams,
const ldmParams_t* ldmParams, const ldmParams_t* ldmParams,
const int isStatic, const int isStatic,
const ZSTD_paramSwitch_e useRowMatchFinder, const ZSTD_ParamSwitch_e useRowMatchFinder,
const size_t buffInSize, const size_t buffInSize,
const size_t buffOutSize, const size_t buffOutSize,
const U64 pledgedSrcSize, const U64 pledgedSrcSize,
@ -1763,7 +1763,7 @@ size_t ZSTD_estimateCCtxSize_usingCCtxParams(const ZSTD_CCtx_params* params)
{ {
ZSTD_compressionParameters const cParams = ZSTD_compressionParameters const cParams =
ZSTD_getCParamsFromCCtxParams(params, ZSTD_CONTENTSIZE_UNKNOWN, 0, ZSTD_cpm_noAttachDict); ZSTD_getCParamsFromCCtxParams(params, ZSTD_CONTENTSIZE_UNKNOWN, 0, ZSTD_cpm_noAttachDict);
ZSTD_paramSwitch_e const useRowMatchFinder = ZSTD_resolveRowMatchFinderMode(params->useRowMatchFinder, ZSTD_ParamSwitch_e const useRowMatchFinder = ZSTD_resolveRowMatchFinderMode(params->useRowMatchFinder,
&cParams); &cParams);
RETURN_ERROR_IF(params->nbWorkers > 0, GENERIC, "Estimate CCtx size is supported for single-threaded compression only."); RETURN_ERROR_IF(params->nbWorkers > 0, GENERIC, "Estimate CCtx size is supported for single-threaded compression only.");
@ -1828,7 +1828,7 @@ size_t ZSTD_estimateCStreamSize_usingCCtxParams(const ZSTD_CCtx_params* params)
size_t const outBuffSize = (params->outBufferMode == ZSTD_bm_buffered) size_t const outBuffSize = (params->outBufferMode == ZSTD_bm_buffered)
? ZSTD_compressBound(blockSize) + 1 ? ZSTD_compressBound(blockSize) + 1
: 0; : 0;
ZSTD_paramSwitch_e const useRowMatchFinder = ZSTD_resolveRowMatchFinderMode(params->useRowMatchFinder, &params->cParams); ZSTD_ParamSwitch_e const useRowMatchFinder = ZSTD_resolveRowMatchFinderMode(params->useRowMatchFinder, &params->cParams);
return ZSTD_estimateCCtxSize_usingCCtxParams_internal( return ZSTD_estimateCCtxSize_usingCCtxParams_internal(
&cParams, &params->ldmParams, 1, useRowMatchFinder, inBuffSize, outBuffSize, &cParams, &params->ldmParams, 1, useRowMatchFinder, inBuffSize, outBuffSize,
@ -1993,7 +1993,7 @@ static size_t
ZSTD_reset_matchState(ZSTD_MatchState_t* ms, ZSTD_reset_matchState(ZSTD_MatchState_t* ms,
ZSTD_cwksp* ws, ZSTD_cwksp* ws,
const ZSTD_compressionParameters* cParams, const ZSTD_compressionParameters* cParams,
const ZSTD_paramSwitch_e useRowMatchFinder, const ZSTD_ParamSwitch_e useRowMatchFinder,
const ZSTD_compResetPolicy_e crp, const ZSTD_compResetPolicy_e crp,
const ZSTD_indexResetPolicy_e forceResetIndex, const ZSTD_indexResetPolicy_e forceResetIndex,
const ZSTD_resetTarget_e forWho) const ZSTD_resetTarget_e forWho)
@ -3074,7 +3074,7 @@ ZSTD_entropyCompressSeqStore(
/* ZSTD_selectBlockCompressor() : /* ZSTD_selectBlockCompressor() :
* Not static, but internal use only (used by long distance matcher) * Not static, but internal use only (used by long distance matcher)
* assumption : strat is a valid strategy */ * assumption : strat is a valid strategy */
ZSTD_BlockCompressor_f ZSTD_selectBlockCompressor(ZSTD_strategy strat, ZSTD_paramSwitch_e useRowMatchFinder, ZSTD_dictMode_e dictMode) ZSTD_BlockCompressor_f ZSTD_selectBlockCompressor(ZSTD_strategy strat, ZSTD_ParamSwitch_e useRowMatchFinder, ZSTD_dictMode_e dictMode)
{ {
static const ZSTD_BlockCompressor_f blockCompressor[4][ZSTD_STRATEGY_MAX+1] = { static const ZSTD_BlockCompressor_f blockCompressor[4][ZSTD_STRATEGY_MAX+1] = {
{ ZSTD_compressBlock_fast /* default for 0 */, { ZSTD_compressBlock_fast /* default for 0 */,
@ -3250,7 +3250,7 @@ ZSTD_transferSequences_wBlockDelim(ZSTD_CCtx* cctx,
ZSTD_SequencePosition* seqPos, ZSTD_SequencePosition* seqPos,
const ZSTD_Sequence* const inSeqs, size_t inSeqsSize, const ZSTD_Sequence* const inSeqs, size_t inSeqsSize,
const void* src, size_t blockSize, const void* src, size_t blockSize,
ZSTD_paramSwitch_e externalRepSearch); ZSTD_ParamSwitch_e externalRepSearch);
typedef enum { ZSTDbss_compress, ZSTDbss_noCompress } ZSTD_BuildSeqStore_e; typedef enum { ZSTDbss_compress, ZSTDbss_noCompress } ZSTD_BuildSeqStore_e;
@ -5591,7 +5591,7 @@ static size_t ZSTD_initCDict_internal(
static ZSTD_CDict* ZSTD_createCDict_advanced_internal(size_t dictSize, static ZSTD_CDict* ZSTD_createCDict_advanced_internal(size_t dictSize,
ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictLoadMethod_e dictLoadMethod,
ZSTD_compressionParameters cParams, ZSTD_compressionParameters cParams,
ZSTD_paramSwitch_e useRowMatchFinder, ZSTD_ParamSwitch_e useRowMatchFinder,
int enableDedicatedDictSearch, int enableDedicatedDictSearch,
ZSTD_customMem customMem) ZSTD_customMem customMem)
{ {
@ -5746,7 +5746,7 @@ const ZSTD_CDict* ZSTD_initStaticCDict(
ZSTD_dictContentType_e dictContentType, ZSTD_dictContentType_e dictContentType,
ZSTD_compressionParameters cParams) ZSTD_compressionParameters cParams)
{ {
ZSTD_paramSwitch_e const useRowMatchFinder = ZSTD_resolveRowMatchFinderMode(ZSTD_ps_auto, &cParams); ZSTD_ParamSwitch_e const useRowMatchFinder = ZSTD_resolveRowMatchFinderMode(ZSTD_ps_auto, &cParams);
/* enableDedicatedDictSearch == 1 ensures matchstate is not too small in case this CDict will be used for DDS + row hash */ /* enableDedicatedDictSearch == 1 ensures matchstate is not too small in case this CDict will be used for DDS + row hash */
size_t const matchStateSize = ZSTD_sizeof_matchState(&cParams, useRowMatchFinder, /* enableDedicatedDictSearch */ 1, /* forCCtx */ 0); size_t const matchStateSize = ZSTD_sizeof_matchState(&cParams, useRowMatchFinder, /* enableDedicatedDictSearch */ 1, /* forCCtx */ 0);
size_t const neededSize = ZSTD_cwksp_alloc_size(sizeof(ZSTD_CDict)) size_t const neededSize = ZSTD_cwksp_alloc_size(sizeof(ZSTD_CDict))
@ -6626,7 +6626,7 @@ ZSTD_transferSequences_wBlockDelim(ZSTD_CCtx* cctx,
ZSTD_SequencePosition* seqPos, ZSTD_SequencePosition* seqPos,
const ZSTD_Sequence* const inSeqs, size_t inSeqsSize, const ZSTD_Sequence* const inSeqs, size_t inSeqsSize,
const void* src, size_t blockSize, const void* src, size_t blockSize,
ZSTD_paramSwitch_e externalRepSearch) ZSTD_ParamSwitch_e externalRepSearch)
{ {
U32 idx = seqPos->idx; U32 idx = seqPos->idx;
U32 const startIdx = idx; U32 const startIdx = idx;
@ -6727,7 +6727,7 @@ ZSTD_transferSequences_noDelim(ZSTD_CCtx* cctx,
ZSTD_SequencePosition* seqPos, ZSTD_SequencePosition* seqPos,
const ZSTD_Sequence* const inSeqs, size_t inSeqsSize, const ZSTD_Sequence* const inSeqs, size_t inSeqsSize,
const void* src, size_t blockSize, const void* src, size_t blockSize,
ZSTD_paramSwitch_e externalRepSearch) ZSTD_ParamSwitch_e externalRepSearch)
{ {
U32 idx = seqPos->idx; U32 idx = seqPos->idx;
U32 startPosInSequence = seqPos->posInSequence; U32 startPosInSequence = seqPos->posInSequence;
@ -6847,9 +6847,18 @@ ZSTD_transferSequences_noDelim(ZSTD_CCtx* cctx,
return bytesAdjustment; return bytesAdjustment;
} }
typedef size_t (*ZSTD_SequenceCopier_f) (ZSTD_CCtx* cctx, ZSTD_SequencePosition* seqPos, /* @seqPos represents a position within @inSeqs,
const ZSTD_Sequence* const inSeqs, size_t inSeqsSize, * it is read and updated by this function,
const void* src, size_t blockSize, ZSTD_paramSwitch_e externalRepSearch); * once the goal to produce a block of size @blockSize is reached.
* @return: nb of bytes missing to reach @blockSize goal.
* so (@blockSize - @return) represents the nb of bytes ingested from @src.
*/
typedef size_t (*ZSTD_SequenceCopier_f)(ZSTD_CCtx* cctx,
ZSTD_SequencePosition* seqPos,
const ZSTD_Sequence* const inSeqs, size_t inSeqsSize,
const void* src, size_t blockSize,
ZSTD_ParamSwitch_e externalRepSearch);
static ZSTD_SequenceCopier_f ZSTD_selectSequenceCopier(ZSTD_SequenceFormat_e mode) static ZSTD_SequenceCopier_f ZSTD_selectSequenceCopier(ZSTD_SequenceFormat_e mode)
{ {
assert(ZSTD_cParam_withinBounds(ZSTD_c_blockDelimiters, (int)mode)); assert(ZSTD_cParam_withinBounds(ZSTD_c_blockDelimiters, (int)mode));
@ -6941,7 +6950,6 @@ ZSTD_compressSequences_internal(ZSTD_CCtx* cctx,
while (remaining) { while (remaining) {
size_t compressedSeqsSize; size_t compressedSeqsSize;
size_t cBlockSize; size_t cBlockSize;
size_t additionalByteAdjustment;
size_t blockSize = determine_blockSize(cctx->appliedParams.blockDelimiters, size_t blockSize = determine_blockSize(cctx->appliedParams.blockDelimiters,
cctx->blockSize, remaining, cctx->blockSize, remaining,
inSeqs, inSeqsSize, seqPos); inSeqs, inSeqsSize, seqPos);
@ -6950,9 +6958,10 @@ ZSTD_compressSequences_internal(ZSTD_CCtx* cctx,
assert(blockSize <= remaining); assert(blockSize <= remaining);
ZSTD_resetSeqStore(&cctx->seqStore); ZSTD_resetSeqStore(&cctx->seqStore);
additionalByteAdjustment = sequenceCopier(cctx, &seqPos, inSeqs, inSeqsSize, ip, blockSize, cctx->appliedParams.searchForExternalRepcodes); { size_t adjust = sequenceCopier(cctx, &seqPos, inSeqs, inSeqsSize, ip, blockSize, cctx->appliedParams.searchForExternalRepcodes);
FORWARD_IF_ERROR(additionalByteAdjustment, "Bad sequence copy"); FORWARD_IF_ERROR(adjust, "Bad sequence copy");
blockSize -= additionalByteAdjustment; blockSize -= adjust;
}
/* If blocks are too small, emit as a nocompress block */ /* If blocks are too small, emit as a nocompress block */
/* TODO: See 3090. We reduced MIN_CBLOCK_SIZE from 3 to 2 so to compensate we are adding /* TODO: See 3090. We reduced MIN_CBLOCK_SIZE from 3 to 2 so to compensate we are adding

View File

@ -247,7 +247,7 @@ typedef struct {
U32 offCodeSumBasePrice; /* to compare to log2(offreq) */ U32 offCodeSumBasePrice; /* to compare to log2(offreq) */
ZSTD_OptPrice_e priceType; /* prices can be determined dynamically, or follow a pre-defined cost structure */ ZSTD_OptPrice_e priceType; /* prices can be determined dynamically, or follow a pre-defined cost structure */
const ZSTD_entropyCTables_t* symbolCosts; /* pre-calculated dictionary statistics */ const ZSTD_entropyCTables_t* symbolCosts; /* pre-calculated dictionary statistics */
ZSTD_paramSwitch_e literalCompressionMode; ZSTD_ParamSwitch_e literalCompressionMode;
} optState_t; } optState_t;
typedef struct { typedef struct {
@ -348,7 +348,7 @@ typedef struct {
} ldmState_t; } ldmState_t;
typedef struct { typedef struct {
ZSTD_paramSwitch_e enableLdm; /* ZSTD_ps_enable to enable LDM. ZSTD_ps_auto by default */ ZSTD_ParamSwitch_e enableLdm; /* ZSTD_ps_enable to enable LDM. ZSTD_ps_auto by default */
U32 hashLog; /* Log size of hashTable */ U32 hashLog; /* Log size of hashTable */
U32 bucketSizeLog; /* Log bucket size for collision resolution, at most 8 */ U32 bucketSizeLog; /* Log bucket size for collision resolution, at most 8 */
U32 minMatchLength; /* Minimum match length */ U32 minMatchLength; /* Minimum match length */
@ -379,7 +379,7 @@ struct ZSTD_CCtx_params_s {
* There is no guarantee that hint is close to actual source size */ * There is no guarantee that hint is close to actual source size */
ZSTD_dictAttachPref_e attachDictPref; ZSTD_dictAttachPref_e attachDictPref;
ZSTD_paramSwitch_e literalCompressionMode; ZSTD_ParamSwitch_e literalCompressionMode;
/* Multithreading: used to pass parameters to mtctx */ /* Multithreading: used to pass parameters to mtctx */
int nbWorkers; int nbWorkers;
@ -411,14 +411,14 @@ struct ZSTD_CCtx_params_s {
* then levels are sorted in increasing cpu budget, from 2 (fastest) to 6 (slowest). * then levels are sorted in increasing cpu budget, from 2 (fastest) to 6 (slowest).
* Highest @preBlockSplitter_level combines well with @postBlockSplitter. * Highest @preBlockSplitter_level combines well with @postBlockSplitter.
*/ */
ZSTD_paramSwitch_e postBlockSplitter; ZSTD_ParamSwitch_e postBlockSplitter;
int preBlockSplitter_level; int preBlockSplitter_level;
/* Adjust the max block size*/ /* Adjust the max block size*/
size_t maxBlockSize; size_t maxBlockSize;
/* Param for deciding whether to use row-based matchfinder */ /* Param for deciding whether to use row-based matchfinder */
ZSTD_paramSwitch_e useRowMatchFinder; ZSTD_ParamSwitch_e useRowMatchFinder;
/* Always load a dictionary in ext-dict mode (not prefix mode)? */ /* Always load a dictionary in ext-dict mode (not prefix mode)? */
int deterministicRefPrefix; int deterministicRefPrefix;
@ -427,7 +427,7 @@ struct ZSTD_CCtx_params_s {
ZSTD_customMem customMem; ZSTD_customMem customMem;
/* Controls prefetching in some dictMatchState matchfinders */ /* Controls prefetching in some dictMatchState matchfinders */
ZSTD_paramSwitch_e prefetchCDictTables; ZSTD_ParamSwitch_e prefetchCDictTables;
/* Controls whether zstd will fall back to an internal matchfinder /* Controls whether zstd will fall back to an internal matchfinder
* if the external matchfinder returns an error code. */ * if the external matchfinder returns an error code. */
@ -440,7 +440,7 @@ struct ZSTD_CCtx_params_s {
ZSTD_sequenceProducer_F extSeqProdFunc; ZSTD_sequenceProducer_F extSeqProdFunc;
/* Controls repcode search in external sequence parsing */ /* Controls repcode search in external sequence parsing */
ZSTD_paramSwitch_e searchForExternalRepcodes; ZSTD_ParamSwitch_e searchForExternalRepcodes;
}; /* typedef'd to ZSTD_CCtx_params within "zstd.h" */ }; /* typedef'd to ZSTD_CCtx_params within "zstd.h" */
#define COMPRESS_SEQUENCES_WORKSPACE_SIZE (sizeof(unsigned) * (MaxSeq + 2)) #define COMPRESS_SEQUENCES_WORKSPACE_SIZE (sizeof(unsigned) * (MaxSeq + 2))
@ -582,7 +582,7 @@ typedef enum {
typedef size_t (*ZSTD_BlockCompressor_f) ( typedef size_t (*ZSTD_BlockCompressor_f) (
ZSTD_MatchState_t* bs, SeqStore_t* seqStore, U32 rep[ZSTD_REP_NUM], ZSTD_MatchState_t* bs, SeqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
void const* src, size_t srcSize); void const* src, size_t srcSize);
ZSTD_BlockCompressor_f ZSTD_selectBlockCompressor(ZSTD_strategy strat, ZSTD_paramSwitch_e rowMatchfinderMode, ZSTD_dictMode_e dictMode); ZSTD_BlockCompressor_f ZSTD_selectBlockCompressor(ZSTD_strategy strat, ZSTD_ParamSwitch_e rowMatchfinderMode, ZSTD_dictMode_e dictMode);
MEM_STATIC U32 ZSTD_LLcode(U32 litLength) MEM_STATIC U32 ZSTD_LLcode(U32 litLength)

View File

@ -666,7 +666,7 @@ void ZSTD_ldm_skipRawSeqStoreBytes(RawSeqStore_t* rawSeqStore, size_t nbBytes) {
size_t ZSTD_ldm_blockCompress(RawSeqStore_t* rawSeqStore, size_t ZSTD_ldm_blockCompress(RawSeqStore_t* rawSeqStore,
ZSTD_MatchState_t* ms, SeqStore_t* seqStore, U32 rep[ZSTD_REP_NUM], ZSTD_MatchState_t* ms, SeqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
ZSTD_paramSwitch_e useRowMatchFinder, ZSTD_ParamSwitch_e useRowMatchFinder,
void const* src, size_t srcSize) void const* src, size_t srcSize)
{ {
const ZSTD_compressionParameters* const cParams = &ms->cParams; const ZSTD_compressionParameters* const cParams = &ms->cParams;

View File

@ -66,7 +66,7 @@ size_t ZSTD_ldm_generateSequences(
*/ */
size_t ZSTD_ldm_blockCompress(RawSeqStore_t* rawSeqStore, size_t ZSTD_ldm_blockCompress(RawSeqStore_t* rawSeqStore,
ZSTD_MatchState_t* ms, SeqStore_t* seqStore, U32 rep[ZSTD_REP_NUM], ZSTD_MatchState_t* ms, SeqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
ZSTD_paramSwitch_e useRowMatchFinder, ZSTD_ParamSwitch_e useRowMatchFinder,
void const* src, size_t srcSize); void const* src, size_t srcSize);
/** /**

View File

@ -1433,14 +1433,15 @@ typedef enum {
} ZSTD_literalCompressionMode_e; } ZSTD_literalCompressionMode_e;
typedef enum { typedef enum {
/* Note: This enum controls features which are conditionally beneficial. Zstd typically will make a final /* Note: This enum controls features which are conditionally beneficial.
* decision on whether or not to enable the feature (ZSTD_ps_auto), but setting the switch to ZSTD_ps_enable * Zstd can take a decision on whether or not to enable the feature (ZSTD_ps_auto),
* or ZSTD_ps_disable allow for a force enable/disable the feature. * but setting the switch to ZSTD_ps_enable or ZSTD_ps_disable force enable/disable the feature.
*/ */
ZSTD_ps_auto = 0, /* Let the library automatically determine whether the feature shall be enabled */ ZSTD_ps_auto = 0, /* Let the library automatically determine whether the feature shall be enabled */
ZSTD_ps_enable = 1, /* Force-enable the feature */ ZSTD_ps_enable = 1, /* Force-enable the feature */
ZSTD_ps_disable = 2 /* Do not use the feature */ ZSTD_ps_disable = 2 /* Do not use the feature */
} ZSTD_paramSwitch_e; } ZSTD_ParamSwitch_e;
#define ZSTD_paramSwitch_e ZSTD_ParamSwitch_e /* old name */
/*************************************** /***************************************
* Frame header and size functions * Frame header and size functions
@ -2024,7 +2025,7 @@ ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const vo
* See the comments on that enum for an explanation of the feature. */ * See the comments on that enum for an explanation of the feature. */
#define ZSTD_c_forceAttachDict ZSTD_c_experimentalParam4 #define ZSTD_c_forceAttachDict ZSTD_c_experimentalParam4
/* Controlled with ZSTD_paramSwitch_e enum. /* Controlled with ZSTD_ParamSwitch_e enum.
* Default is ZSTD_ps_auto. * Default is ZSTD_ps_auto.
* Set to ZSTD_ps_disable to never compress literals. * Set to ZSTD_ps_disable to never compress literals.
* Set to ZSTD_ps_enable to always compress literals. (Note: uncompressed literals * Set to ZSTD_ps_enable to always compress literals. (Note: uncompressed literals
@ -2215,7 +2216,7 @@ ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const vo
#define ZSTD_c_splitAfterSequences ZSTD_c_experimentalParam13 #define ZSTD_c_splitAfterSequences ZSTD_c_experimentalParam13
/* ZSTD_c_useRowMatchFinder /* ZSTD_c_useRowMatchFinder
* Controlled with ZSTD_paramSwitch_e enum. * Controlled with ZSTD_ParamSwitch_e enum.
* Default is ZSTD_ps_auto. * Default is ZSTD_ps_auto.
* Set to ZSTD_ps_disable to never use row-based matchfinder. * Set to ZSTD_ps_disable to never use row-based matchfinder.
* Set to ZSTD_ps_enable to force usage of row-based matchfinder. * Set to ZSTD_ps_enable to force usage of row-based matchfinder.
@ -2247,7 +2248,7 @@ ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const vo
#define ZSTD_c_deterministicRefPrefix ZSTD_c_experimentalParam15 #define ZSTD_c_deterministicRefPrefix ZSTD_c_experimentalParam15
/* ZSTD_c_prefetchCDictTables /* ZSTD_c_prefetchCDictTables
* Controlled with ZSTD_paramSwitch_e enum. Default is ZSTD_ps_auto. * Controlled with ZSTD_ParamSwitch_e enum. Default is ZSTD_ps_auto.
* *
* In some situations, zstd uses CDict tables in-place rather than copying them * In some situations, zstd uses CDict tables in-place rather than copying them
* into the working context. (See docs on ZSTD_dictAttachPref_e above for details). * into the working context. (See docs on ZSTD_dictAttachPref_e above for details).

View File

@ -109,7 +109,7 @@ typedef struct {
int ldmHashLog; int ldmHashLog;
int ldmBucketSizeLog; int ldmBucketSizeLog;
int ldmHashRateLog; int ldmHashRateLog;
ZSTD_paramSwitch_e literalCompressionMode; ZSTD_ParamSwitch_e literalCompressionMode;
int useRowMatchFinder; /* use row-based matchfinder if possible */ int useRowMatchFinder; /* use row-based matchfinder if possible */
} BMK_advancedParams_t; } BMK_advancedParams_t;

View File

@ -423,7 +423,7 @@ void FIO_setTestMode(FIO_prefs_t* const prefs, int testMode) {
void FIO_setLiteralCompressionMode( void FIO_setLiteralCompressionMode(
FIO_prefs_t* const prefs, FIO_prefs_t* const prefs,
ZSTD_paramSwitch_e mode) { ZSTD_ParamSwitch_e mode) {
prefs->literalCompressionMode = mode; prefs->literalCompressionMode = mode;
} }
@ -485,7 +485,7 @@ void FIO_setPassThroughFlag(FIO_prefs_t* const prefs, int value) {
prefs->passThrough = (value != 0); prefs->passThrough = (value != 0);
} }
void FIO_setMMapDict(FIO_prefs_t* const prefs, ZSTD_paramSwitch_e value) void FIO_setMMapDict(FIO_prefs_t* const prefs, ZSTD_ParamSwitch_e value)
{ {
prefs->mmapDict = value; prefs->mmapDict = value;
} }

View File

@ -95,7 +95,7 @@ void FIO_setSrcSizeHint(FIO_prefs_t* const prefs, size_t srcSizeHint);
void FIO_setTestMode(FIO_prefs_t* const prefs, int testMode); void FIO_setTestMode(FIO_prefs_t* const prefs, int testMode);
void FIO_setLiteralCompressionMode( void FIO_setLiteralCompressionMode(
FIO_prefs_t* const prefs, FIO_prefs_t* const prefs,
ZSTD_paramSwitch_e mode); ZSTD_ParamSwitch_e mode);
void FIO_setProgressSetting(FIO_progressSetting_e progressSetting); void FIO_setProgressSetting(FIO_progressSetting_e progressSetting);
void FIO_setNotificationLevel(int level); void FIO_setNotificationLevel(int level);
@ -106,7 +106,7 @@ void FIO_setContentSize(FIO_prefs_t* const prefs, int value);
void FIO_displayCompressionParameters(const FIO_prefs_t* prefs); void FIO_displayCompressionParameters(const FIO_prefs_t* prefs);
void FIO_setAsyncIOFlag(FIO_prefs_t* const prefs, int value); void FIO_setAsyncIOFlag(FIO_prefs_t* const prefs, int value);
void FIO_setPassThroughFlag(FIO_prefs_t* const prefs, int value); void FIO_setPassThroughFlag(FIO_prefs_t* const prefs, int value);
void FIO_setMMapDict(FIO_prefs_t* const prefs, ZSTD_paramSwitch_e value); void FIO_setMMapDict(FIO_prefs_t* const prefs, ZSTD_ParamSwitch_e value);
/* FIO_ctx_t functions */ /* FIO_ctx_t functions */
void FIO_setNbFilesTotal(FIO_ctx_t* const fCtx, int value); void FIO_setNbFilesTotal(FIO_ctx_t* const fCtx, int value);

View File

@ -53,7 +53,7 @@ typedef struct FIO_prefs_s {
size_t targetCBlockSize; size_t targetCBlockSize;
int srcSizeHint; int srcSizeHint;
int testMode; int testMode;
ZSTD_paramSwitch_e literalCompressionMode; ZSTD_ParamSwitch_e literalCompressionMode;
/* IO preferences */ /* IO preferences */
int removeSrcFile; int removeSrcFile;
@ -69,7 +69,7 @@ typedef struct FIO_prefs_s {
int contentSize; int contentSize;
int allowBlockDevices; int allowBlockDevices;
int passThrough; int passThrough;
ZSTD_paramSwitch_e mmapDict; ZSTD_ParamSwitch_e mmapDict;
} FIO_prefs_t; } FIO_prefs_t;
typedef enum {FIO_mallocDict, FIO_mmapDict} FIO_dictBufferType_t; typedef enum {FIO_mallocDict, FIO_mmapDict} FIO_dictBufferType_t;

View File

@ -849,8 +849,8 @@ int main(int argCount, const char* argv[])
ultra=0, ultra=0,
contentSize=1, contentSize=1,
removeSrcFile=0; removeSrcFile=0;
ZSTD_paramSwitch_e mmapDict=ZSTD_ps_auto; ZSTD_ParamSwitch_e mmapDict=ZSTD_ps_auto;
ZSTD_paramSwitch_e useRowMatchFinder = ZSTD_ps_auto; ZSTD_ParamSwitch_e useRowMatchFinder = ZSTD_ps_auto;
FIO_compressionType_t cType = FIO_zstdCompression; FIO_compressionType_t cType = FIO_zstdCompression;
int nbWorkers = -1; /* -1 means unset */ int nbWorkers = -1; /* -1 means unset */
double compressibility = -1.0; /* lorem ipsum generator */ double compressibility = -1.0; /* lorem ipsum generator */
@ -891,7 +891,7 @@ int main(int argCount, const char* argv[])
#ifndef ZSTD_NOBENCH #ifndef ZSTD_NOBENCH
BMK_advancedParams_t benchParams = BMK_initAdvancedParams(); BMK_advancedParams_t benchParams = BMK_initAdvancedParams();
#endif #endif
ZSTD_paramSwitch_e literalCompressionMode = ZSTD_ps_auto; ZSTD_ParamSwitch_e literalCompressionMode = ZSTD_ps_auto;
/* init */ /* init */
checkLibVersion(); checkLibVersion();