From 6025465e42dfce6d3312b14a80e7614bc52b362c Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 16 Jan 2018 15:34:41 -0800 Subject: [PATCH] ZSTDMT : minor CCtx memory optimization can be useful when a compression job only has small amount of data to compress. --- lib/compress/zstdmt_compress.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/compress/zstdmt_compress.c b/lib/compress/zstdmt_compress.c index 47b8923a..0dadda28 100644 --- a/lib/compress/zstdmt_compress.c +++ b/lib/compress/zstdmt_compress.c @@ -346,7 +346,7 @@ void ZSTDMT_compressChunk(void* jobDescription) assert(job->firstChunk); /* only allowed for first job */ if (ZSTD_isError(initError)) { job->cSize = initError; goto _endJob; } } else { /* srcStart points at reloaded section */ - U64 const pledgedSrcSize = job->firstChunk ? job->fullFrameSize : ZSTD_CONTENTSIZE_UNKNOWN; + U64 const pledgedSrcSize = job->firstChunk ? job->fullFrameSize : job->srcSize; ZSTD_CCtx_params jobParams = job->params; /* do not modify job->params ! copy it, modify the copy */ { size_t const forceWindowError = ZSTD_CCtxParam_setParameter(&jobParams, ZSTD_p_forceMaxWindow, !job->firstChunk); if (ZSTD_isError(forceWindowError)) { @@ -355,7 +355,7 @@ void ZSTDMT_compressChunk(void* jobDescription) } } { size_t const initError = ZSTD_compressBegin_advanced_internal(cctx, job->srcStart, job->prefixSize, ZSTD_dm_rawContent, /* load dictionary in "content-only" mode (no header analysis) */ - NULL, + NULL, /*cdict*/ jobParams, pledgedSrcSize); if (ZSTD_isError(initError)) { job->cSize = initError; @@ -404,8 +404,8 @@ void ZSTDMT_compressChunk(void* jobDescription) if (ZSTD_isError(cSize)) { job->cSize = cSize; goto _endJob; } /* stats */ job->cSize += cSize; - job->readSize = job->srcSize; } + job->readSize = job->srcSize; } #endif