feat(compress): move CDict table copy leaf to Rust
ZSTD_copyCDictTableIntoCCtx only transformed tagged CDict match-table entries or copied untagged entries; context-owned table selection remains in C. Keep that policy and both call sites in C, forwarding the selected flag through a narrow ABI. Rust removes the frozen eight-bit short-cache tag or uses copy_nonoverlapping for C memcpy-equivalent copying without adding validation. Test Plan: - Focused and full compression Rust tests passed (2 and 267 tests). - `make -B -C lib -j2 lib` passed. - `make -C tests -j2 fuzzer` passed. - `./tests/fuzzer -s4560 -t47 -i48 -v` passed. - Clippy normal/benches/tests before and after `cargo +nightly fmt` passed. - `git diff --check` and `git diff --cached --check` passed.
This commit is contained in:
@@ -66,6 +66,8 @@ int ZSTD_rust_simpleCompress2Level(const void* cctx);
|
||||
int ZSTD_rust_simpleCompressStream2Level(const void* cctx);
|
||||
void ZSTD_rust_reduceTable(U32* table, U32 size, U32 reducerValue,
|
||||
int preserveMark);
|
||||
void ZSTD_rust_copyCDictTableIntoCCtx(U32* dst, U32 const* src,
|
||||
size_t tableSize, int tagged);
|
||||
U64 ZSTD_rust_advanceHashSalt(U64 hashSalt, U64 hashSaltEntropy);
|
||||
int ZSTD_rust_indexTooCloseToMax(size_t nextSrcBaseOffset);
|
||||
int ZSTD_rust_dictTooBig(size_t loadedDictSize);
|
||||
@@ -1877,18 +1879,9 @@ ZSTD_resetCCtx_byAttachingCDict(ZSTD_CCtx* cctx,
|
||||
|
||||
static void ZSTD_copyCDictTableIntoCCtx(U32* dst, U32 const* src, size_t tableSize,
|
||||
ZSTD_compressionParameters const* cParams) {
|
||||
if (ZSTD_CDictIndicesAreTagged(cParams)){
|
||||
/* Remove tags from the CDict table if they are present.
|
||||
* See docs on "short cache" in zstd_compress_internal.h for context. */
|
||||
size_t i;
|
||||
for (i = 0; i < tableSize; i++) {
|
||||
U32 const taggedIndex = src[i];
|
||||
U32 const index = taggedIndex >> ZSTD_SHORT_CACHE_TAG_BITS;
|
||||
dst[i] = index;
|
||||
}
|
||||
} else {
|
||||
ZSTD_memcpy(dst, src, tableSize * sizeof(U32));
|
||||
}
|
||||
ZSTD_STATIC_ASSERT(ZSTD_SHORT_CACHE_TAG_BITS == 8);
|
||||
ZSTD_rust_copyCDictTableIntoCCtx(dst, src, tableSize,
|
||||
ZSTD_CDictIndicesAreTagged(cParams));
|
||||
}
|
||||
|
||||
static size_t ZSTD_resetCCtx_byCopyingCDict(ZSTD_CCtx* cctx,
|
||||
|
||||
Reference in New Issue
Block a user