mirror of
https://github.com/facebook/zstd.git
synced 2025-11-29 00:04:37 -05:00
Improved speed of ZSTD_decompressStream()
When ZSTD_decompressStream() detects that there is enough space in dst to complete decompression in a single pass, delegates to ZSTD_decompress(), for an extra ~5% speed boost
This commit is contained in:
parent
1d7f30f9d4
commit
d1760113ec
@ -2100,7 +2100,7 @@ size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx,
|
|||||||
{
|
{
|
||||||
/* pass content and size in case legacy frames are encountered */
|
/* pass content and size in case legacy frames are encountered */
|
||||||
return ZSTD_decompressMultiFrame(dctx, dst, dstCapacity, src, srcSize,
|
return ZSTD_decompressMultiFrame(dctx, dst, dstCapacity, src, srcSize,
|
||||||
ddict->dictContent, ddict->dictSize,
|
NULL, 0,
|
||||||
ddict);
|
ddict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2301,6 +2301,20 @@ size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inB
|
|||||||
break;
|
break;
|
||||||
} }
|
} }
|
||||||
|
|
||||||
|
/* check for single-pass mode opportunity */
|
||||||
|
if (zds->fParams.frameContentSize
|
||||||
|
&& (U64)(size_t)(oend-op) >= zds->fParams.frameContentSize) {
|
||||||
|
size_t const cSize = ZSTD_findFrameCompressedSize(istart, iend-istart);
|
||||||
|
if (cSize <= (size_t)(iend-istart)) {
|
||||||
|
size_t const decompressedSize = ZSTD_decompress_usingDDict(zds->dctx, op, oend-op, istart, cSize, zds->ddict);
|
||||||
|
if (ZSTD_isError(decompressedSize)) return decompressedSize;
|
||||||
|
ip += cSize;
|
||||||
|
op += decompressedSize;
|
||||||
|
zds->stage = zdss_init;
|
||||||
|
someMoreWork = 0;
|
||||||
|
break;
|
||||||
|
} }
|
||||||
|
|
||||||
/* Consume header */
|
/* Consume header */
|
||||||
ZSTD_refDDict(zds->dctx, zds->ddict);
|
ZSTD_refDDict(zds->dctx, zds->ddict);
|
||||||
{ size_t const h1Size = ZSTD_nextSrcSizeToDecompress(zds->dctx); /* == ZSTD_frameHeaderSize_prefix */
|
{ size_t const h1Size = ZSTD_nextSrcSizeToDecompress(zds->dctx); /* == ZSTD_frameHeaderSize_prefix */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user