fix(compress): restore optimal parser strategy compatibility

Match the original optimal-parser statistics for zero-possible symbols, complete the shortest-path fallback when the forward pass runs past its final position, and refresh the projected window state for the ultra2 second pass. Keep the simple Rust frame leaf restricted to the match finders it implements so lazy and optimal strategies retain their stateful lifecycle.

Test Plan:

- cargo test --manifest-path rust/Cargo.toml --no-default-features --features compression (135 passed)

- cargo test --manifest-path rust/Cargo.toml --no-default-features --features compression zstd_opt (3 passed)

- make -B -C tests -j2 test-cli-tests (41 passed)

- make -B -C tests -j2 test-zstream (84 named tests and fuzzer suites passed)

- cargo clippy --manifest-path rust/Cargo.toml

- cargo clippy --manifest-path rust/Cargo.toml --benches

- cargo clippy --manifest-path rust/Cargo.toml --tests
This commit is contained in:
2026-07-18 02:39:58 +02:00
parent be02682a31
commit 49b3405d63
2 changed files with 87 additions and 3 deletions
+11
View File
@@ -4528,6 +4528,11 @@ int ZSTD_rust_simpleCompress2Level(const void* opaqueCctx)
{
ZSTD_CCtx const* const cctx = (ZSTD_CCtx const*)opaqueCctx;
ZSTD_CCtx_params const* const params = cctx ? &cctx->requestedParams : NULL;
ZSTD_compressionParameters const cParams = params
? ZSTD_getCParams_internal(params->compressionLevel,
ZSTD_CONTENTSIZE_UNKNOWN, 0,
ZSTD_cpm_noAttachDict)
: (ZSTD_compressionParameters){ 0 };
if (params == NULL
|| params->format != ZSTD_f_zstd1
|| params->fParams.contentSizeFlag == 0
@@ -4579,6 +4584,12 @@ int ZSTD_rust_simpleCompress2Level(const void* opaqueCctx)
|| cctx->localDict.cdict != NULL) {
return (-2147483647 - 1);
}
/* The Rust frame leaf currently implements only the fast and double-fast
* match finders. Keep lazy and optimal strategies on the stateful path,
* which owns their strategy-specific match-table lifecycle. */
if (cParams.strategy != ZSTD_fast && cParams.strategy != ZSTD_dfast) {
return (-2147483647 - 1);
}
return params->compressionLevel;
}