refactor(compress): remove pure C parameter forwarders

Call the existing Rust parameter leaves directly from the compression
orchestration layer. This removes the redundant dedicated-dictionary
parameter reversal, C-parameter equality, and advanced CCtx-parameter
allocation wrappers while keeping all private context/resource callbacks and
debug assertion behavior in place.

Test Plan:
- clang -fsyntax-only on lib/compress/zstd_compress.c
- git diff --check
- Full capped native/upstream suite pending after this commit
This commit is contained in:
2026-07-20 11:34:31 +02:00
parent 58606b18aa
commit d1a7a53e5b
+7 -29
View File
@@ -3579,15 +3579,9 @@ static ZSTD_CCtx_params ZSTD_makeCCtxParamsFromCParams(
return cctxParams; return cctxParams;
} }
static ZSTD_CCtx_params* ZSTD_createCCtxParams_advanced(
ZSTD_customMem customMem)
{
return ZSTD_rust_createCCtxParams(customMem);
}
ZSTD_CCtx_params* ZSTD_createCCtxParams(void) ZSTD_CCtx_params* ZSTD_createCCtxParams(void)
{ {
return ZSTD_createCCtxParams_advanced(ZSTD_defaultCMem); return ZSTD_rust_createCCtxParams(ZSTD_defaultCMem);
} }
size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params) size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params)
@@ -3789,9 +3783,6 @@ size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx* cctx, unsigned long long pledgedSr
&cctx->pledgedSrcSizePlusOne); &cctx->pledgedSrcSizePlusOne);
} }
static void ZSTD_dedicatedDictSearch_revertCParams(
ZSTD_compressionParameters* cParams);
size_t ZSTD_CCtx_loadDictionary_advanced( size_t ZSTD_CCtx_loadDictionary_advanced(
ZSTD_CCtx* cctx, ZSTD_CCtx* cctx,
const void* dict, size_t dictSize, const void* dict, size_t dictSize,
@@ -4220,12 +4211,6 @@ size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx)
return ZSTD_rust_toFlushNow(&state); return ZSTD_rust_toFlushNow(&state);
} }
static void ZSTD_assertEqualCParams(ZSTD_compressionParameters cParams1,
ZSTD_compressionParameters cParams2)
{
ZSTD_rust_params_assertEqualCParams(cParams1, cParams2);
}
void ZSTD_reset_compressedBlockState(ZSTD_compressedBlockState_t* bs) void ZSTD_reset_compressedBlockState(ZSTD_compressedBlockState_t* bs)
{ {
ZSTD_rust_resetCompressedBlockState(bs); ZSTD_rust_resetCompressedBlockState(bs);
@@ -4922,7 +4907,9 @@ static size_t ZSTD_rust_resetCCtx_byAttachingCDict_reset(
/* Resize working context table params for input only, since the dict /* Resize working context table params for input only, since the dict
* has its own tables. */ * has its own tables. */
if (cdict->matchState.dedicatedDictSearch) { if (cdict->matchState.dedicatedDictSearch) {
ZSTD_dedicatedDictSearch_revertCParams(&adjusted_cdict_cParams); adjusted_cdict_cParams =
ZSTD_rust_params_dedicatedDictSearch_revertCParams(
adjusted_cdict_cParams);
} }
params.cParams = ZSTD_adjustCParams_internal( params.cParams = ZSTD_adjustCParams_internal(
adjusted_cdict_cParams, pledgedSrcSize, adjusted_cdict_cParams, pledgedSrcSize,
@@ -5466,7 +5453,8 @@ static void ZSTD_rust_buildSeqStore_prepareMatchState(void* context,
DEBUGLOG(5, "ZSTD_buildSeqStore (srcSize=%zu)", srcSize); DEBUGLOG(5, "ZSTD_buildSeqStore (srcSize=%zu)", srcSize);
(void)srcSize; (void)srcSize;
/* Assert that we have correctly flushed the ctx params into the ms's copy. */ /* Assert that we have correctly flushed the ctx params into the ms's copy. */
ZSTD_assertEqualCParams(zc->appliedParams.cParams, ms->cParams); ZSTD_rust_params_assertEqualCParams(zc->appliedParams.cParams,
ms->cParams);
/* required for optimal parser to read stats from dictionary */ /* required for optimal parser to read stats from dictionary */
ms->opt.symbolCosts = &zc->blockState.prevCBlock->entropy; ms->opt.symbolCosts = &zc->blockState.prevCBlock->entropy;
/* tell the optimal parser how we expect to compress literals */ /* tell the optimal parser how we expect to compress literals */
@@ -6114,7 +6102,7 @@ static void ZSTD_loadDictionaryContent_assertCParams(void* opaque)
{ {
ZSTD_loadDictionaryContent_context const* const context = ZSTD_loadDictionaryContent_context const* const context =
(const ZSTD_loadDictionaryContent_context*)opaque; (const ZSTD_loadDictionaryContent_context*)opaque;
ZSTD_assertEqualCParams(context->params->cParams, ZSTD_rust_params_assertEqualCParams(context->params->cParams,
context->matchState->cParams); context->matchState->cParams);
} }
@@ -8641,16 +8629,6 @@ size_t ZSTD_endStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output)
/* The compression-level tables (formerly included from clevels.h) live in /* The compression-level tables (formerly included from clevels.h) live in
* rust/src/zstd_compress_params.rs. */ * rust/src/zstd_compress_params.rs. */
/**
* Reverses the adjustment applied to cparams when enabling dedicated dict
* search. This is used to recover the params set to be used in the working
* context. (Otherwise, those tables would also grow.)
*/
static void ZSTD_dedicatedDictSearch_revertCParams(
ZSTD_compressionParameters* cParams) {
*cParams = ZSTD_rust_params_dedicatedDictSearch_revertCParams(*cParams);
}
/*! ZSTD_getCParams_internal() : /*! ZSTD_getCParams_internal() :
* @return ZSTD_compressionParameters structure for a selected compression level, srcSize and dictSize. * @return ZSTD_compressionParameters structure for a selected compression level, srcSize and dictSize.
* Note: srcSizeHint 0 means 0, use ZSTD_CONTENTSIZE_UNKNOWN for unknown. * Note: srcSizeHint 0 means 0, use ZSTD_CONTENTSIZE_UNKNOWN for unknown.