Clear the Dictionary When Sliding the Window
This commit is contained in:
@@ -1240,6 +1240,7 @@ static size_t ZSTD_resetCCtx_usingCDict(ZSTD_CCtx* cctx,
|
|||||||
- cdict->matchState.window.base);
|
- cdict->matchState.window.base);
|
||||||
ZSTD_window_clear(&cctx->blockState.matchState.window);
|
ZSTD_window_clear(&cctx->blockState.matchState.window);
|
||||||
}
|
}
|
||||||
|
cctx->blockState.matchState.loadedDictEnd = cctx->blockState.matchState.window.dictLimit;
|
||||||
} else {
|
} else {
|
||||||
DEBUGLOG(4, "copying dictionary into context");
|
DEBUGLOG(4, "copying dictionary into context");
|
||||||
/* copy tables */
|
/* copy tables */
|
||||||
@@ -2313,8 +2314,9 @@ static size_t ZSTD_compress_frameChunk (ZSTD_CCtx* cctx,
|
|||||||
if (ms->nextToUpdate < correction) ms->nextToUpdate = 0;
|
if (ms->nextToUpdate < correction) ms->nextToUpdate = 0;
|
||||||
else ms->nextToUpdate -= correction;
|
else ms->nextToUpdate -= correction;
|
||||||
ms->loadedDictEnd = 0;
|
ms->loadedDictEnd = 0;
|
||||||
|
ms->dictMatchState = NULL;
|
||||||
}
|
}
|
||||||
ZSTD_window_enforceMaxDist(&ms->window, ip + blockSize, maxDist, &ms->loadedDictEnd);
|
ZSTD_window_enforceMaxDist(&ms->window, ip + blockSize, maxDist, &ms->loadedDictEnd, &ms->dictMatchState);
|
||||||
if (ms->nextToUpdate < ms->window.lowLimit) ms->nextToUpdate = ms->window.lowLimit;
|
if (ms->nextToUpdate < ms->window.lowLimit) ms->nextToUpdate = ms->window.lowLimit;
|
||||||
|
|
||||||
{ size_t cSize = ZSTD_compressBlock_internal(cctx,
|
{ size_t cSize = ZSTD_compressBlock_internal(cctx,
|
||||||
|
|||||||
@@ -520,10 +520,10 @@ MEM_STATIC U32 ZSTD_window_hasExtDict(ZSTD_window_t const window)
|
|||||||
*/
|
*/
|
||||||
MEM_STATIC ZSTD_dictMode_e ZSTD_matchState_dictMode(const ZSTD_matchState_t *ms)
|
MEM_STATIC ZSTD_dictMode_e ZSTD_matchState_dictMode(const ZSTD_matchState_t *ms)
|
||||||
{
|
{
|
||||||
return ms->dictMatchState != NULL ?
|
return ZSTD_window_hasExtDict(ms->window) ?
|
||||||
ZSTD_dictMatchState :
|
ZSTD_extDict :
|
||||||
ZSTD_window_hasExtDict(ms->window) ?
|
ms->dictMatchState != NULL ?
|
||||||
ZSTD_extDict :
|
ZSTD_dictMatchState :
|
||||||
ZSTD_noDict;
|
ZSTD_noDict;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -605,7 +605,8 @@ MEM_STATIC U32 ZSTD_window_correctOverflow(ZSTD_window_t* window, U32 cycleLog,
|
|||||||
*/
|
*/
|
||||||
MEM_STATIC void ZSTD_window_enforceMaxDist(ZSTD_window_t* window,
|
MEM_STATIC void ZSTD_window_enforceMaxDist(ZSTD_window_t* window,
|
||||||
void const* srcEnd, U32 maxDist,
|
void const* srcEnd, U32 maxDist,
|
||||||
U32* loadedDictEndPtr)
|
U32* loadedDictEndPtr,
|
||||||
|
const ZSTD_matchState_t** dictMatchStatePtr)
|
||||||
{
|
{
|
||||||
U32 const current = (U32)((BYTE const*)srcEnd - window->base);
|
U32 const current = (U32)((BYTE const*)srcEnd - window->base);
|
||||||
U32 loadedDictEnd = loadedDictEndPtr != NULL ? *loadedDictEndPtr : 0;
|
U32 loadedDictEnd = loadedDictEndPtr != NULL ? *loadedDictEndPtr : 0;
|
||||||
@@ -619,6 +620,8 @@ MEM_STATIC void ZSTD_window_enforceMaxDist(ZSTD_window_t* window,
|
|||||||
}
|
}
|
||||||
if (loadedDictEndPtr)
|
if (loadedDictEndPtr)
|
||||||
*loadedDictEndPtr = 0;
|
*loadedDictEndPtr = 0;
|
||||||
|
if (dictMatchStatePtr)
|
||||||
|
*dictMatchStatePtr = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -508,7 +508,7 @@ size_t ZSTD_ldm_generateSequences(
|
|||||||
* * Try invalidation after the sequence generation and test the
|
* * Try invalidation after the sequence generation and test the
|
||||||
* the offset against maxDist directly.
|
* the offset against maxDist directly.
|
||||||
*/
|
*/
|
||||||
ZSTD_window_enforceMaxDist(&ldmState->window, chunkEnd, maxDist, NULL);
|
ZSTD_window_enforceMaxDist(&ldmState->window, chunkEnd, maxDist, NULL, NULL);
|
||||||
/* 3. Generate the sequences for the chunk, and get newLeftoverSize. */
|
/* 3. Generate the sequences for the chunk, and get newLeftoverSize. */
|
||||||
newLeftoverSize = ZSTD_ldm_generateSequences_internal(
|
newLeftoverSize = ZSTD_ldm_generateSequences_internal(
|
||||||
ldmState, sequences, params, chunkStart, chunkSize);
|
ldmState, sequences, params, chunkStart, chunkSize);
|
||||||
|
|||||||
Reference in New Issue
Block a user