]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Add ldm enable condition in ZSTD_resetCCtx_internal
authorsenhuang42 <senhuang96@fb.com>
Mon, 19 Oct 2020 14:26:17 +0000 (10:26 -0400)
committersenhuang42 <senhuang96@fb.com>
Mon, 19 Oct 2020 14:26:17 +0000 (10:26 -0400)
lib/compress/zstd_compress.c

index b1bb9fa10219ef0ea38a246b455dfb64d5471efd..434c23000d80def36ecbd78b709ddffbdfe70099 100644 (file)
@@ -1542,6 +1542,12 @@ static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc,
 
     zc->isFirstBlock = 1;
 
+    if (params.cParams.strategy >= ZSTD_btopt && params.cParams.windowLog >= 27) {
+        /* Enable LDM by default for optimal parser and window size >= 128MB */
+        DEBUGLOG(4, "LDM enabled by default (window size >= 128MB, strategy >= btopt)");
+        params.ldmParams.enableLdm = 1;
+    }
+
     if (params.ldmParams.enableLdm) {
         /* Adjust long distance matching parameters */
         ZSTD_ldm_adjustParameters(&params.ldmParams, &params.cParams);