From e3181cfd325db59dbdeadcaf91b8187f49c5546c Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Wed, 8 Jan 2025 14:25:03 -0800 Subject: [PATCH] minor code doc update --- lib/compress/zstd_compress.c | 16 ++++++++-------- lib/zstd.h | 5 +++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index f6cde3d09..bdf0e8287 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -7196,8 +7196,8 @@ size_t convertSequences_noRepcodes( __m256i vadd = _mm256_add_epi32(vin, addition); /* Check for long length */ - __m256i cmp = _mm256_cmpgt_epi32(vadd, limit); // 0xFFFFFFFF for element > 65535 - int cmp_res = _mm256_movemask_epi8(cmp); + __m256i ll_cmp = _mm256_cmpgt_epi32(vadd, limit); /* 0xFFFFFFFF for element > 65535 */ + int ll_res = _mm256_movemask_epi8(ll_cmp); /* Shuffle bytes so each half gives us the 8 bytes we need */ __m256i vshf = _mm256_shuffle_epi8(vadd, mask); @@ -7228,7 +7228,7 @@ size_t convertSequences_noRepcodes( * indices for lengths correspond to bits [4..7], [8..11], [20..23], [24..27] * => combined mask = 0x0FF00FF0 */ - if (UNLIKELY((cmp_res & 0x0FF00FF0) != 0)) { + if (UNLIKELY((ll_res & 0x0FF00FF0) != 0)) { /* long length detected: let's figure out which one*/ if (inSeqs[i].matchLength > 65535+MINMATCH) { assert(longLen == 0); @@ -7251,12 +7251,12 @@ size_t convertSequences_noRepcodes( /* Handle leftover if @nbSequences is odd */ if (i < nbSequences) { - /* Fallback: process last sequence */ + /* process last sequence */ assert(i == nbSequences - 1); dstSeqs[i].offBase = OFFSET_TO_OFFBASE(inSeqs[i].offset); - /* note: doesn't work if one length is > 65535 */ dstSeqs[i].litLength = (U16)inSeqs[i].litLength; dstSeqs[i].mlBase = (U16)(inSeqs[i].matchLength - MINMATCH); + /* check (unlikely) long lengths > 65535 */ if (UNLIKELY(inSeqs[i].matchLength > 65535+MINMATCH)) { assert(longLen == 0); longLen = i + 1; @@ -7271,8 +7271,8 @@ size_t convertSequences_noRepcodes( } /* the vector implementation could also be ported to SSSE3, - * but since this implementation is targeting modern systems >= Sapphire Rapid, - * it's not useful to develop and maintain code for older platforms (before AVX2) */ + * but since this implementation is targeting modern systems (>= Sapphire Rapid), + * it's not useful to develop and maintain code for older pre-AVX2 platforms */ #else /* no AVX2 */ @@ -7284,9 +7284,9 @@ convertSequences_noRepcodes(SeqDef* dstSeqs, size_t n; for (n=0; n 65535 */ dstSeqs[n].litLength = (U16)inSeqs[n].litLength; dstSeqs[n].mlBase = (U16)(inSeqs[n].matchLength - MINMATCH); + /* check for long length > 65535 */ if (UNLIKELY(inSeqs[n].matchLength > 65535+MINMATCH)) { assert(longLen == 0); longLen = n + 1; diff --git a/lib/zstd.h b/lib/zstd.h index 907a377d1..b8c0644a7 100644 --- a/lib/zstd.h +++ b/lib/zstd.h @@ -1696,7 +1696,8 @@ ZSTD_compressSequences(ZSTD_CCtx* cctx, * - Not compatible with frame checksum, which must be disabled * - If any block is incompressible, will fail and return an error * - @litSize must be == sum of all @.litLength fields in @inSeqs. Any discrepancy will generate an error. - * - the buffer @literals must have a size @litCapacity which is larger than @litSize by at least 8 bytes. + * - @litBufCapacity is the size of the underlying buffer into which literals are written, starting at address @literals. + * @litBufCapacity must be at least 8 bytes larger than @litSize. * - @decompressedSize must be correct, and correspond to the sum of all Sequences. Any discrepancy will generate an error. * @return : final compressed size, or a ZSTD error code. */ @@ -1704,7 +1705,7 @@ ZSTDLIB_STATIC_API size_t ZSTD_compressSequencesAndLiterals(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const ZSTD_Sequence* inSeqs, size_t nbSequences, - const void* literals, size_t litSize, size_t litCapacity, + const void* literals, size_t litSize, size_t litBufCapacity, size_t decompressedSize); -- 2.47.2