feat(compress): move MT input size hint arithmetic to Rust
ZSTDMT_nextInputSizeHint only derives a size_t hint from targetSectionSize and inBuff.filled. Keep the MT context, public/internal entry point, and stream orchestration in C, but delegate those two scalars to Rust. The Rust helper uses wrapping subtraction and preserves the zero-result fallback, including C's wrapped behavior for invalid overfill. Test Plan: - The three compression clippy modes passed before and after `cargo +nightly fmt --manifest-path rust/Cargo.toml`. - Focused Rust tests passed: 5 `mt_next_input_size_hint` tests. - `make -B -C lib -j2 lib` passed. - `make -C tests test-rust-lib-smoke` passed. - `tests/fuzzer -s4560 -t56 -i57 -v` passed: 57 tests completed. - `make -C tests -j2 test-zstream` passed: 84 named, 6,659, and 8,055 randomized tests completed. - `git diff --check` and `git diff --cached --check` passed.
This commit is contained in:
@@ -149,6 +149,8 @@ void ZSTDMT_rust_findSynchronizationPoint(const void* inputSrc, size_t inputSize
|
||||
const void* inBuffStart, size_t inBuffFilled,
|
||||
int rsyncable, U64 primePower, U64 hitMask,
|
||||
size_t* toLoad, int* flush);
|
||||
size_t ZSTDMT_rust_nextInputSizeHint(size_t targetSectionSize,
|
||||
size_t inBuffFilled);
|
||||
|
||||
typedef struct ZSTDMT_bufferPool_s {
|
||||
ZSTDMT_RustBufferPool* rustPool;
|
||||
@@ -1665,9 +1667,8 @@ findSynchronizationPoint(ZSTDMT_CCtx const* mtctx, ZSTD_inBuffer const input)
|
||||
|
||||
size_t ZSTDMT_nextInputSizeHint(const ZSTDMT_CCtx* mtctx)
|
||||
{
|
||||
size_t hintInSize = mtctx->targetSectionSize - mtctx->inBuff.filled;
|
||||
if (hintInSize==0) hintInSize = mtctx->targetSectionSize;
|
||||
return hintInSize;
|
||||
return ZSTDMT_rust_nextInputSizeHint(mtctx->targetSectionSize,
|
||||
mtctx->inBuff.filled);
|
||||
}
|
||||
|
||||
/** ZSTDMT_compressStream_generic() :
|
||||
|
||||
Reference in New Issue
Block a user