Fixes in re Comments
This commit is contained in:
@@ -1207,11 +1207,12 @@ static size_t ZSTD_resetCCtx_usingCDict(ZSTD_CCtx* cctx,
|
|||||||
/* We have a choice between copying the dictionary context into the working
|
/* We have a choice between copying the dictionary context into the working
|
||||||
* context, or referencing the dictionary context from the working context
|
* context, or referencing the dictionary context from the working context
|
||||||
* in-place. We decide here which strategy to use. */
|
* in-place. We decide here which strategy to use. */
|
||||||
int attachDict = ( pledgedSrcSize <= 8 KB
|
const int attachDict = ( pledgedSrcSize <= 8 KB
|
||||||
|| pledgedSrcSize == ZSTD_CONTENTSIZE_UNKNOWN )
|
|| pledgedSrcSize == ZSTD_CONTENTSIZE_UNKNOWN )
|
||||||
&& cdict->cParams.strategy == ZSTD_fast
|
&& cdict->cParams.strategy == ZSTD_fast
|
||||||
&& ZSTD_equivalentCParams(cctx->appliedParams.cParams,
|
&& ZSTD_equivalentCParams(cctx->appliedParams.cParams,
|
||||||
cdict->cParams);
|
cdict->cParams);
|
||||||
|
|
||||||
|
|
||||||
{ unsigned const windowLog = params.cParams.windowLog;
|
{ unsigned const windowLog = params.cParams.windowLog;
|
||||||
assert(windowLog != 0);
|
assert(windowLog != 0);
|
||||||
@@ -1227,7 +1228,9 @@ static size_t ZSTD_resetCCtx_usingCDict(ZSTD_CCtx* cctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (attachDict) {
|
if (attachDict) {
|
||||||
if (cdict->matchState.window.nextSrc - cdict->matchState.window.base == 0) {
|
const U32 cdictLen = (U32)( cdict->matchState.window.nextSrc
|
||||||
|
- cdict->matchState.window.base);
|
||||||
|
if (cdictLen == 0) {
|
||||||
/* don't even attach dictionaries with no contents */
|
/* don't even attach dictionaries with no contents */
|
||||||
DEBUGLOG(4, "skipping attaching empty dictionary");
|
DEBUGLOG(4, "skipping attaching empty dictionary");
|
||||||
} else {
|
} else {
|
||||||
@@ -1236,15 +1239,12 @@ static size_t ZSTD_resetCCtx_usingCDict(ZSTD_CCtx* cctx,
|
|||||||
|
|
||||||
/* prep working match state so dict matches never have negative indices
|
/* prep working match state so dict matches never have negative indices
|
||||||
* when they are translated to the working context's index space. */
|
* when they are translated to the working context's index space. */
|
||||||
if (cctx->blockState.matchState.window.dictLimit <
|
if (cctx->blockState.matchState.window.dictLimit < cdictLen) {
|
||||||
(U32)(cdict->matchState.window.nextSrc - cdict->matchState.window.base)) {
|
|
||||||
cctx->blockState.matchState.window.nextSrc =
|
cctx->blockState.matchState.window.nextSrc =
|
||||||
cctx->blockState.matchState.window.base +
|
cctx->blockState.matchState.window.base + cdictLen;
|
||||||
( cdict->matchState.window.nextSrc
|
|
||||||
- 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;
|
cctx->blockState.matchState.loadedDictEnd = params.forceWindow ? 0 : cdictLen;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUGLOG(4, "copying dictionary into context");
|
DEBUGLOG(4, "copying dictionary into context");
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ size_t ZSTD_compressBlock_fast_generic(
|
|||||||
const U32 dictIndexDelta = dictMode == ZSTD_dictMatchState ?
|
const U32 dictIndexDelta = dictMode == ZSTD_dictMatchState ?
|
||||||
prefixLowestIndex - (U32)(dictEnd - dictBase) :
|
prefixLowestIndex - (U32)(dictEnd - dictBase) :
|
||||||
0;
|
0;
|
||||||
|
const U32 dictAndPrefixLength = (U32)(ip - prefixLowest + dictEnd - dictLowest);
|
||||||
|
|
||||||
assert(dictMode == ZSTD_noDict || dictMode == ZSTD_dictMatchState);
|
assert(dictMode == ZSTD_noDict || dictMode == ZSTD_dictMatchState);
|
||||||
|
|
||||||
@@ -83,13 +84,18 @@ size_t ZSTD_compressBlock_fast_generic(
|
|||||||
|| prefixLowestIndex >= (U32)(dictEnd - dictBase));
|
|| prefixLowestIndex >= (U32)(dictEnd - dictBase));
|
||||||
|
|
||||||
/* init */
|
/* init */
|
||||||
ip += (ip - prefixLowest + dictEnd - dictLowest == 0);
|
ip += (dictAndPrefixLength == 0);
|
||||||
{ U32 const maxRep = dictMode == ZSTD_dictMatchState ?
|
if (dictMode == ZSTD_noDict) {
|
||||||
(U32)(ip - prefixLowest + dictEnd - dictLowest) :
|
U32 const maxRep = (U32)(ip - prefixLowest);
|
||||||
(U32)(ip - prefixLowest);
|
|
||||||
if (offset_2 > maxRep) offsetSaved = offset_2, offset_2 = 0;
|
if (offset_2 > maxRep) offsetSaved = offset_2, offset_2 = 0;
|
||||||
if (offset_1 > maxRep) offsetSaved = offset_1, offset_1 = 0;
|
if (offset_1 > maxRep) offsetSaved = offset_1, offset_1 = 0;
|
||||||
}
|
}
|
||||||
|
if (dictMode == ZSTD_dictMatchState) {
|
||||||
|
/* dictMatchState repCode checks don't currently handle repCode == 0
|
||||||
|
* disabling. */
|
||||||
|
assert(offset_1 <= dictAndPrefixLength);
|
||||||
|
assert(offset_2 <= dictAndPrefixLength);
|
||||||
|
}
|
||||||
|
|
||||||
/* Main Search Loop */
|
/* Main Search Loop */
|
||||||
while (ip < ilimit) { /* < instead of <=, because repcode check at (ip+1) */
|
while (ip < ilimit) { /* < instead of <=, because repcode check at (ip+1) */
|
||||||
@@ -169,8 +175,7 @@ size_t ZSTD_compressBlock_fast_generic(
|
|||||||
while (ip <= ilimit) {
|
while (ip <= ilimit) {
|
||||||
U32 const current2 = (U32)(ip-base);
|
U32 const current2 = (U32)(ip-base);
|
||||||
U32 const repIndex2 = current2 - offset_2;
|
U32 const repIndex2 = current2 - offset_2;
|
||||||
const BYTE* repMatch2 = dictMode == ZSTD_dictMatchState
|
const BYTE* repMatch2 = repIndex2 < prefixLowestIndex ?
|
||||||
&& repIndex2 < prefixLowestIndex ?
|
|
||||||
dictBase - dictIndexDelta + repIndex2 :
|
dictBase - dictIndexDelta + repIndex2 :
|
||||||
base + repIndex2;
|
base + repIndex2;
|
||||||
if ( ((U32)((prefixLowestIndex-1) - (U32)repIndex2) >= 3 /* intentional overflow */)
|
if ( ((U32)((prefixLowestIndex-1) - (U32)repIndex2) >= 3 /* intentional overflow */)
|
||||||
|
|||||||
Reference in New Issue
Block a user