]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed performance regression with ZSTD_decompress() on small files
authorYann Collet <cyan@fb.com>
Wed, 24 May 2017 20:15:19 +0000 (13:15 -0700)
committerYann Collet <cyan@fb.com>
Wed, 24 May 2017 20:15:19 +0000 (13:15 -0700)
memset() was a quick fix to initialization problems,
but initialize too much space (tables, buffers)
which show up in decompression speed of ZSTD_decompress()
since it needs to recreate DCtx at each invocation.

Fixed by only initialization relevant pointers and size fields.

lib/decompress/zstd_decompress.c

index aabfa6d948a3976da8e4fdd3b1f93dcf49ee19dc..8cf500445ea005b796c3492e9e3455a7c8930fc0 100644 (file)
@@ -195,11 +195,16 @@ ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem)
 
     dctx = (ZSTD_DCtx*)ZSTD_malloc(sizeof(ZSTD_DCtx), customMem);
     if (!dctx) return NULL;
-    memset(dctx, 0, sizeof(*dctx));
     memcpy(&dctx->customMem, &customMem, sizeof(customMem));
     ZSTD_decompressBegin(dctx);   /* cannot fail */
     dctx->streamStage = zdss_init;
     dctx->maxWindowSize = ZSTD_MAXWINDOWSIZE_DEFAULT;
+    dctx->ddict   = NULL;
+    dctx->ddictLocal = NULL;
+    dctx->inBuff  = NULL;
+    dctx->outBuff = NULL;
+    dctx->inBuffSize = 0;
+    dctx->outBuffSize= 0;
     return dctx;
 }