refactor(compress): inline external sequence transfer

Project the external sequence producer callback directly into the Rust
block-delimited sequence transfer leaf.  Remove the redundant C forwarding
wrapper while preserving the C-facing sequence conversion API.

Test Plan:
- ulimit -v 41943040; make -j1
- ulimit -v 41943040; make -j1 -C tests test-zstream ZSTREAM_TESTTIME=-T2s
- ulimit -v 41943040; make -j1 -C tests fuzzer
- ulimit -v 41943040; make -j1 -C tests test-fuzzer FUZZERTEST=-T3s FUZZER_FLAGS=--no-big-tests
This commit is contained in:
2026-07-20 02:17:32 +02:00
parent 919d138f02
commit 2c605eef4e
+20 -40
View File
@@ -5080,22 +5080,32 @@ void ZSTD_resetSeqStore(SeqStore_t* ssPtr)
ZSTD_rust_resetSeqStore(ssPtr);
}
static size_t
ZSTD_transferSequences_wBlockDelim(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 size_t ZSTD_rust_externalSequenceProducer_transfer(
void* context, ZSTD_SequencePosition* seqPos,
const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
const void* src, size_t blockSize)
{
ZSTD_CCtx* const zc = (ZSTD_CCtx*)context;
return ZSTD_transferSequences_wBlockDelim(
zc, seqPos, inSeqs, inSeqsSize, src, blockSize,
zc->appliedParams.searchForExternalRepcodes);
U32 dictSize;
if (zc->cdict) {
dictSize = (U32)zc->cdict->dictContentSize;
} else if (zc->prefixDict.dict) {
dictSize = (U32)zc->prefixDict.dictSize;
} else {
dictSize = 0;
}
return ZSTD_rust_transferSequencesWBlockDelim(
&zc->seqStore, seqPos, inSeqs, inSeqsSize,
(const BYTE*)src, blockSize,
(int)zc->appliedParams.searchForExternalRepcodes,
zc->blockState.prevCBlock->rep,
zc->blockState.nextCBlock->rep,
dictSize,
zc->appliedParams.validateSequences,
zc->appliedParams.cParams.minMatch,
zc->appliedParams.cParams.windowLog,
ZSTD_hasExtSeqProd(&zc->appliedParams));
}
static void ZSTD_rust_buildSeqStore_skipSmallBlock(void* context, size_t srcSize)
@@ -7824,36 +7834,6 @@ size_t ZSTD_compress2_c(ZSTD_CCtx* cctx,
return ZSTD_rust_compress2(&state, dst, dstCapacity, src, srcSize);
}
/* The explicit-delimiter adapter is also used by the external sequence
* producer path. Keep that C-context-facing call site separate from the
* Rust-owned compressSequences block loop. */
static size_t
ZSTD_transferSequences_wBlockDelim(ZSTD_CCtx* cctx,
ZSTD_SequencePosition* seqPos,
const ZSTD_Sequence* const inSeqs, size_t inSeqsSize,
const void* src, size_t blockSize,
ZSTD_ParamSwitch_e externalRepSearch)
{
U32 dictSize;
if (cctx->cdict) {
dictSize = (U32)cctx->cdict->dictContentSize;
} else if (cctx->prefixDict.dict) {
dictSize = (U32)cctx->prefixDict.dictSize;
} else {
dictSize = 0;
}
return ZSTD_rust_transferSequencesWBlockDelim(
&cctx->seqStore, seqPos, inSeqs, inSeqsSize,
(const BYTE*)src, blockSize, (int)externalRepSearch,
cctx->blockState.prevCBlock->rep,
cctx->blockState.nextCBlock->rep, dictSize,
cctx->appliedParams.validateSequences,
cctx->appliedParams.cParams.minMatch,
cctx->appliedParams.cParams.windowLog,
ZSTD_hasExtSeqProd(&cctx->appliedParams));
}
/* The public symbol remains C-facing for fullbench and the sequence API, but
* the sequence-store conversion itself is Rust-owned. */
size_t ZSTD_convertBlockSequences(ZSTD_CCtx* cctx,