From: Yann Collet Date: Wed, 4 Nov 2015 12:57:24 +0000 (+0100) Subject: small compression improvement X-Git-Tag: zstd-0.3.3^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b241e9deb7d207f87658f79856b2717a19c25162;p=thirdparty%2Fzstd.git small compression improvement --- diff --git a/lib/zstdhc.c b/lib/zstdhc.c index 716213fd3..e90b7f3a6 100644 --- a/lib/zstdhc.c +++ b/lib/zstdhc.c @@ -292,7 +292,7 @@ size_t ZSTD_HC_insertBtAndFindBestMatch ( const U32 windowLow = windowSize >= current ? 0 : current - windowSize; U32* smallerPtr = bt + 2*(current&btMask); U32* largerPtr = bt + 2*(current&btMask) + 1; - U32 bestLength = 0; + size_t bestLength = 0; U32 dummy32; /* to be nullified at the end */ hashTable[h] = (U32)(ip-base); /* Update Hash Table */ @@ -307,8 +307,8 @@ size_t ZSTD_HC_insertBtAndFindBestMatch ( if (matchLength > bestLength) { - bestLength = (U32)matchLength; - *offsetPtr = current - matchIndex; + if ( (4*(int)(matchLength-bestLength)) > (int)(ZSTD_highbit(current-matchIndex+1) - ZSTD_highbit(offsetPtr[0]+1)) ) + bestLength = matchLength, *offsetPtr = current - matchIndex; if (ip+matchLength == iend) /* equal : no way to know if inf or sup */ break; /* drop, next to null, to guarantee consistency (is there a way to do better ?) */ } diff --git a/lib/zstdhc_static.h b/lib/zstdhc_static.h index 06174fcde..bbe157134 100644 --- a/lib/zstdhc_static.h +++ b/lib/zstdhc_static.h @@ -116,10 +116,10 @@ static const ZSTD_HC_parameters ZSTD_HC_defaultParameters[ZSTD_HC_MAX_CLEVEL+1] { 21, 21, 22, 6, 5, ZSTD_HC_lazydeep }, /* level 14 */ { 22, 21, 22, 6, 5, ZSTD_HC_lazydeep }, /* level 15 */ { 22, 21, 22, 5, 5, ZSTD_HC_btlazy2 }, /* level 16 */ - { 22, 22, 23, 5, 5, ZSTD_HC_btlazy2 }, /* level 17 */ + { 22, 23, 22, 4, 5, ZSTD_HC_btlazy2 }, /* level 17 */ { 22, 22, 23, 7, 5, ZSTD_HC_btlazy2 }, /* level 18 */ - { 24, 24, 22, 7, 5, ZSTD_HC_btlazy2 }, /* level 19 */ - { 25, 25, 23, 8, 5, ZSTD_HC_btlazy2 }, /* level 20 */ + { 23, 23, 23, 7, 5, ZSTD_HC_btlazy2 }, /* level 19 */ + { 24, 25, 23, 8, 5, ZSTD_HC_btlazy2 }, /* level 20 */ { 25, 25, 23, 8, 5, ZSTD_HC_btlazy2 }, /* level 21 */ { 25, 25, 23, 8, 5, ZSTD_HC_btlazy2 }, /* level 22 */ { 25, 25, 23, 8, 5, ZSTD_HC_btlazy2 }, /* level 23 */ diff --git a/programs/paramgrill.c b/programs/paramgrill.c index f7cfef98e..40033a6a3 100644 --- a/programs/paramgrill.c +++ b/programs/paramgrill.c @@ -696,6 +696,7 @@ static void BMK_benchMem(void* srcBuffer, size_t srcSize) if (g_singleRun) { BMK_result_t testResult; + ZSTD_HC_validateParams(&g_params, g_blockSize ? g_blockSize : srcSize); BMK_benchParam(&testResult, srcBuffer, srcSize, ctx, g_params); DISPLAY("\n"); return; @@ -978,7 +979,8 @@ int main(int argc, char** argv) argument++; while ((*argument>= '0') && (*argument<='9')) { - if (*argument++) g_params.strategy = ZSTD_HC_lazy; + g_params.strategy = (ZSTD_HC_strategy)((U32)g_params.strategy *10); + g_params.strategy = (ZSTD_HC_strategy)((U32)g_params.strategy + *argument++ - '0'); } continue; case 'L':