Make loadedDictEnd an Index, not the Dict Len
This commit is contained in:
parent
7ef85e0618
commit
298d24fa57
@ -1209,6 +1209,8 @@ static size_t ZSTD_resetCCtx_usingCDict(ZSTD_CCtx* cctx,
|
|||||||
* in-place. We decide here which strategy to use. */
|
* in-place. We decide here which strategy to use. */
|
||||||
const int attachDict = ( pledgedSrcSize <= 8 KB
|
const int attachDict = ( pledgedSrcSize <= 8 KB
|
||||||
|| pledgedSrcSize == ZSTD_CONTENTSIZE_UNKNOWN )
|
|| pledgedSrcSize == ZSTD_CONTENTSIZE_UNKNOWN )
|
||||||
|
&& !params.forceWindow /* dictMatchState isn't correctly
|
||||||
|
* handled in _enforceMaxDist */
|
||||||
&& cdict->cParams.strategy == ZSTD_fast
|
&& cdict->cParams.strategy == ZSTD_fast
|
||||||
&& ZSTD_equivalentCParams(cctx->appliedParams.cParams,
|
&& ZSTD_equivalentCParams(cctx->appliedParams.cParams,
|
||||||
cdict->cParams);
|
cdict->cParams);
|
||||||
@ -1244,7 +1246,7 @@ static size_t ZSTD_resetCCtx_usingCDict(ZSTD_CCtx* cctx,
|
|||||||
cctx->blockState.matchState.window.base + cdictLen;
|
cctx->blockState.matchState.window.base + cdictLen;
|
||||||
ZSTD_window_clear(&cctx->blockState.matchState.window);
|
ZSTD_window_clear(&cctx->blockState.matchState.window);
|
||||||
}
|
}
|
||||||
cctx->blockState.matchState.loadedDictEnd = params.forceWindow ? 0 : cdictLen;
|
cctx->blockState.matchState.loadedDictEnd = cctx->blockState.matchState.window.dictLimit;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUGLOG(4, "copying dictionary into context");
|
DEBUGLOG(4, "copying dictionary into context");
|
||||||
|
@ -594,14 +594,20 @@ MEM_STATIC U32 ZSTD_window_correctOverflow(ZSTD_window_t* window, U32 cycleLog,
|
|||||||
* ZSTD_window_enforceMaxDist():
|
* ZSTD_window_enforceMaxDist():
|
||||||
* Updates lowLimit so that:
|
* Updates lowLimit so that:
|
||||||
* (srcEnd - base) - lowLimit == maxDist + loadedDictEnd
|
* (srcEnd - base) - lowLimit == maxDist + loadedDictEnd
|
||||||
|
*
|
||||||
* This allows a simple check that index >= lowLimit to see if index is valid.
|
* This allows a simple check that index >= lowLimit to see if index is valid.
|
||||||
* This must be called before a block compression call, with srcEnd as the block
|
* This must be called before a block compression call, with srcEnd as the block
|
||||||
* source end.
|
* source end.
|
||||||
|
*
|
||||||
* If loadedDictEndPtr is not NULL, we set it to zero once we update lowLimit.
|
* If loadedDictEndPtr is not NULL, we set it to zero once we update lowLimit.
|
||||||
* This is because dictionaries are allowed to be referenced as long as the last
|
* This is because dictionaries are allowed to be referenced as long as the last
|
||||||
* byte of the dictionary is in the window, but once they are out of range,
|
* byte of the dictionary is in the window, but once they are out of range,
|
||||||
* they cannot be referenced. If loadedDictEndPtr is NULL, we use
|
* they cannot be referenced. If loadedDictEndPtr is NULL, we use
|
||||||
* loadedDictEnd == 0.
|
* loadedDictEnd == 0.
|
||||||
|
*
|
||||||
|
* In normal dict mode, the dict is between lowLimit and dictLimit. In
|
||||||
|
* dictMatchState mode, lowLimit and dictLimit are the same, and the dictionary
|
||||||
|
* is below them. forceWindow and dictMatchState are therefore incompatible.
|
||||||
*/
|
*/
|
||||||
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,
|
||||||
|
@ -72,7 +72,7 @@ size_t ZSTD_compressBlock_fast_generic(
|
|||||||
const BYTE* const dictEnd = dictMode == ZSTD_dictMatchState ?
|
const BYTE* const dictEnd = dictMode == ZSTD_dictMatchState ?
|
||||||
dms->window.nextSrc : NULL;
|
dms->window.nextSrc : NULL;
|
||||||
const U32 dictIndexDelta = dictMode == ZSTD_dictMatchState ?
|
const U32 dictIndexDelta = dictMode == ZSTD_dictMatchState ?
|
||||||
prefixLowestIndex - (U32)(dictEnd - dictBase) :
|
ms->loadedDictEnd - (U32)(dictEnd - dictBase) :
|
||||||
0;
|
0;
|
||||||
const U32 dictAndPrefixLength = (U32)(ip - prefixLowest + dictEnd - dictLowest);
|
const U32 dictAndPrefixLength = (U32)(ip - prefixLowest + dictEnd - dictLowest);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user