]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
minor refactor for clarity
authorYann Collet <cyan@fb.com>
Mon, 26 Feb 2024 22:06:34 +0000 (14:06 -0800)
committerYann Collet <cyan@fb.com>
Mon, 26 Feb 2024 22:06:34 +0000 (14:06 -0800)
since we can ensure that nbSubBlocks>0

lib/compress/zstd_compress_superblock.c

index a9e9493bed3b8101367a880a334fcea16b330318..295ccf3049806ea9ccb3f2b35c8a0e2cc45013d9 100644 (file)
@@ -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;