Skip to content

Commit

Permalink
Set hashSalt when copying dict table, don't memset tag table when not…
Browse files Browse the repository at this point in the history
… needed
  • Loading branch information
yoniko committed Jan 24, 2023
1 parent a4ea4a3 commit 53f926f
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions lib/compress/zstd_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -1926,17 +1926,6 @@ ZSTD_reset_matchState(ZSTD_matchState_t* ms,
}
ms->hashSalt = 0;
}
#if ZSTD_MEMORY_SANITIZER
else {
/* The rowHash algorithm has the ability to work with uninitialized tag space.
* It doesn't matter if the tag space is initially correct or not,
* at worst it will incorrectly "hint" at a match position
* which is then properly filtered out by indices analysis.
* There is also no requirement to start the series of tag from position "0".
* */
__msan_unpoison(ms->tagTable, tagTableSize);
}
#endif
}
{ /* Switch to 32-entry rows if searchLog is 5 (or more) */
U32 const rowLog = BOUNDED(4, cParams->searchLog, 6);
Expand Down Expand Up @@ -2340,10 +2329,11 @@ static size_t ZSTD_resetCCtx_byCopyingCDict(ZSTD_CCtx* cctx,
}
/* copy tag table */
if (ZSTD_rowMatchFinderUsed(cdict_cParams->strategy, cdict->useRowMatchFinder)) {
size_t const tagTableSize = hSize*sizeof(U16);
size_t const tagTableSize = hSize * sizeof(U16);
ZSTD_memcpy(cctx->blockState.matchState.tagTable,
cdict->matchState.tagTable,
tagTableSize);
cdict->matchState.tagTable,
tagTableSize);
cctx->blockState.matchState.hashSalt = cdict->matchState.hashSalt;
}
}

Expand Down Expand Up @@ -4657,8 +4647,6 @@ static size_t ZSTD_loadDictionaryContent(ZSTD_matchState_t* ms,
} else {
assert(params->useRowMatchFinder != ZSTD_ps_auto);
if (params->useRowMatchFinder == ZSTD_ps_enable) {
size_t const tagTableSize = ((size_t)1 << params->cParams.hashLog) * sizeof(U16);
ZSTD_memset(ms->tagTable, 0, tagTableSize);
ZSTD_row_update(ms, iend-HASH_READ_SIZE);
DEBUGLOG(4, "Using row-based hash table for lazy dict");
} else {
Expand Down

0 comments on commit 53f926f

Please sign in to comment.