feat(compress): move simple strategy selection into Rust
The Rust simple-compression entry points already owned the dispatch, but ZSTD_rust_compressCCtxStrategy still called the C parameter cascade to decide whether a fast Rust frame path was safe. That left a small policy leaf in the C implementation and made the dispatch boundary harder to test in isolation. Implement the helper in Rust by using the existing Rust table-selection and C-parameter-adjustment functions with the same source-size, dictionary-mode, and automatic-adjustment inputs as the C code. Leave only the C ABI declaration and add tests for the table thresholds, default-level behavior, and negative fast-level behavior. The private context reset and fallback compression paths remain unchanged. Test Plan: - `cargo test --manifest-path rust/Cargo.toml --lib zstd_compress -- --test-threads=1` -- passed (234 tests). - `cargo clippy --manifest-path rust/Cargo.toml --lib -- -D warnings` -- passed. - `cargo +nightly fmt --manifest-path rust/Cargo.toml -- --check` -- passed. - `make -B -C lib -j2 lib` -- passed. - `make -C tests -j2 test-rust-lib-smoke` -- passed. - Full-target clippy remains blocked by pre-existing test-only `manual_repeat_n` and `manual_dangling_ptr` warnings outside this seam.
This commit is contained in:
@@ -3849,13 +3849,6 @@ size_t ZSTD_compress_usingDict(ZSTD_CCtx* cctx,
|
||||
|
||||
/* The Rust simple API still needs the C-owned context reset, but does not
|
||||
* cross the private context layout. */
|
||||
int ZSTD_rust_compressCCtxStrategy(size_t srcSize, int compressionLevel)
|
||||
{
|
||||
ZSTD_parameters const params = ZSTD_getParams_internal(
|
||||
compressionLevel, srcSize, 0, ZSTD_cpm_noAttachDict);
|
||||
return (int)params.cParams.strategy;
|
||||
}
|
||||
|
||||
size_t ZSTD_rust_resetCCtxForSimpleCompression(void* cctx)
|
||||
{
|
||||
return ZSTD_CCtx_reset((ZSTD_CCtx*)cctx, ZSTD_reset_session_and_parameters);
|
||||
|
||||
Reference in New Issue
Block a user