]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
coalesce block+header size (buffered mode)
authorYann Collet <yann.collet.73@gmail.com>
Fri, 27 Nov 2015 12:26:38 +0000 (13:26 +0100)
committerYann Collet <yann.collet.73@gmail.com>
Fri, 27 Nov 2015 12:26:38 +0000 (13:26 +0100)
lib/zstd_buffered.c

index 7cf61ed84923e09d5934b1ee9a3f9a256fe15ca9..b7937f1d8f927555399dedd77158f731b51632d6 100644 (file)
@@ -523,7 +523,12 @@ size_t ZBUFF_decompressContinue(ZBUFF_DCtx* zbc, void* dst, size_t* maxDstSizePt
     *srcSizePtr = ip-istart;
     *maxDstSizePtr = op-ostart;
 
-    return ZSTD_nextSrcSizeToDecompress(zbc->zc) - zbc->inPos;
+    {
+        size_t nextSrcSizeHint = ZSTD_nextSrcSizeToDecompress(zbc->zc);
+        if (nextSrcSizeHint > 3) nextSrcSizeHint+= 3;   /* get the next block header while at it */
+        nextSrcSizeHint -= zbc->inPos;   /* already loaded*/
+        return nextSrcSizeHint;
+    }
 }