From: Sen Huang Date: Sun, 20 Oct 2019 18:03:09 +0000 (-0400) Subject: Added support for forcing new CDict behavior and updated enum X-Git-Tag: v1.4.4~1^2~15^2~5^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4de8b098af8e4e375d6af5ce17bdffb986209a1;p=thirdparty%2Fzstd.git Added support for forcing new CDict behavior and updated enum --- diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index 634a0f857..ab5b13d01 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -2908,7 +2908,8 @@ static size_t ZSTD_compressBegin_internal(ZSTD_CCtx* cctx, assert(!((dict) && (cdict))); /* either dict or cdict, not both */ if ( (cdict) && (cdict->dictContentSize > 0) - && (pledgedSrcSize < ZSTD_USE_CDICT_PARAMS_CUTOFF || cdict->compressionLevel == 0) ) { + && (pledgedSrcSize < ZSTD_USE_CDICT_PARAMS_CUTOFF || cdict->compressionLevel == 0) + && (params->attachDictPref != ZSTD_dictForceInputParams) ) { return ZSTD_resetCCtx_usingCDict(cctx, cdict, params, pledgedSrcSize, zbuff); } diff --git a/lib/zstd.h b/lib/zstd.h index 667845627..4859733bb 100644 --- a/lib/zstd.h +++ b/lib/zstd.h @@ -1149,7 +1149,7 @@ typedef enum { * to evolve and should be considered only in the context of extremely * advanced performance tuning. * - * Zstd currently supports the use of a CDict in two ways: + * Zstd currently supports the use of a CDict in three ways: * * - The contents of the CDict can be copied into the working context. This * means that the compression can search both the dictionary and input @@ -1164,6 +1164,10 @@ typedef enum { * tables. However, this model incurs no start-up cost (as long as the * working context's tables can be reused). For small inputs, this can be * faster than copying the CDict's tables. + * + * - The CDict's tables are not used at all, and instead we use the working + * context alone to determine how our tables are initialized. This method + * should be used when using a small dictionary to compress a large input. * * Zstd has a simple internal heuristic that selects which strategy to use * at the beginning of a compression. However, if experimentation shows that @@ -1173,6 +1177,7 @@ typedef enum { ZSTD_dictDefaultAttach = 0, /* Use the default heuristic. */ ZSTD_dictForceAttach = 1, /* Never copy the dictionary. */ ZSTD_dictForceCopy = 2, /* Always copy the dictionary. */ + ZSTD_dictForceInputParams = 3, /* Always use input to determine tables */ } ZSTD_dictAttachPref_e; typedef enum {