small compression improvement

dev
Yann Collet 2015-11-04 13:57:24 +01:00
parent 59d7063fbc
commit b241e9deb7
3 changed files with 9 additions and 7 deletions

View File

@ -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 ?) */
}

View File

@ -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 */

View File

@ -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':