From: Yann Collet Date: Mon, 26 Feb 2024 22:06:34 +0000 (-0800) Subject: minor refactor for clarity X-Git-Tag: v1.5.6^2~60^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d23b95d21d5cb9c5378b3537271dbbff7cdb49b7;p=thirdparty%2Fzstd.git minor refactor for clarity since we can ensure that nbSubBlocks>0 --- diff --git a/lib/compress/zstd_compress_superblock.c b/lib/compress/zstd_compress_superblock.c index a9e9493be..295ccf304 100644 --- a/lib/compress/zstd_compress_superblock.c +++ b/lib/compress/zstd_compress_superblock.c @@ -526,9 +526,11 @@ static size_t ZSTD_compressSubBlock_multi(const seqStore_t* seqStorePtr, if (ebs.estBlockSize > srcSize) return 0; /* compress and write sub-blocks */ - for (n=0; n+1 < nbSubBlocks; n++) { + assert(nbSubBlocks>0); + for (n=0; n < nbSubBlocks-1; n++) { /* determine nb of sequences for current sub-block + nbLiterals from next sequence */ - size_t seqCount = sizeBlockSequences(sp, (size_t)(send-sp), avgBlockBudget + blockBudgetSupp, avgLitCost, avgSeqCost, n==0); + size_t const seqCount = sizeBlockSequences(sp, (size_t)(send-sp), + avgBlockBudget + blockBudgetSupp, avgLitCost, avgSeqCost, n==0); /* if reached last sequence : break to last sub-block (simplification) */ assert(seqCount <= (size_t)(send-sp)); if (sp + seqCount == send) break;