Shorten Dict Mode Conditionals in Order to Improve Readability
This commit is contained in:
+14
-13
@@ -785,16 +785,18 @@ ZSTD_compressBlock_lazy_generic(
|
|||||||
searchMax_f const searchMax = searchFuncs[dictMode][searchMethod == search_binaryTree];
|
searchMax_f const searchMax = searchFuncs[dictMode][searchMethod == search_binaryTree];
|
||||||
U32 offset_1 = rep[0], offset_2 = rep[1], savedOffset=0;
|
U32 offset_1 = rep[0], offset_2 = rep[1], savedOffset=0;
|
||||||
|
|
||||||
|
const int isDMS = dictMode == ZSTD_dictMatchState;
|
||||||
|
const int isDDS = dictMode == ZSTD_dedicatedDictSearch;
|
||||||
const ZSTD_matchState_t* const dms = ms->dictMatchState;
|
const ZSTD_matchState_t* const dms = ms->dictMatchState;
|
||||||
const U32 dictLowestIndex = dictMode == ZSTD_dictMatchState || dictMode == ZSTD_dedicatedDictSearch ?
|
const U32 dictLowestIndex = isDMS || isDDS ?
|
||||||
dms->window.dictLimit : 0;
|
dms->window.dictLimit : 0;
|
||||||
const BYTE* const dictBase = dictMode == ZSTD_dictMatchState || dictMode == ZSTD_dedicatedDictSearch ?
|
const BYTE* const dictBase = isDMS || isDDS ?
|
||||||
dms->window.base : NULL;
|
dms->window.base : NULL;
|
||||||
const BYTE* const dictLowest = dictMode == ZSTD_dictMatchState || dictMode == ZSTD_dedicatedDictSearch ?
|
const BYTE* const dictLowest = isDMS || isDDS ?
|
||||||
dictBase + dictLowestIndex : NULL;
|
dictBase + dictLowestIndex : NULL;
|
||||||
const BYTE* const dictEnd = dictMode == ZSTD_dictMatchState || dictMode == ZSTD_dedicatedDictSearch ?
|
const BYTE* const dictEnd = isDMS || isDDS ?
|
||||||
dms->window.nextSrc : NULL;
|
dms->window.nextSrc : NULL;
|
||||||
const U32 dictIndexDelta = dictMode == ZSTD_dictMatchState || dictMode == ZSTD_dedicatedDictSearch ?
|
const U32 dictIndexDelta = isDMS || isDDS ?
|
||||||
prefixLowestIndex - (U32)(dictEnd - dictBase) :
|
prefixLowestIndex - (U32)(dictEnd - dictBase) :
|
||||||
0;
|
0;
|
||||||
const U32 dictAndPrefixLength = (U32)((ip - prefixLowest) + (dictEnd - dictLowest));
|
const U32 dictAndPrefixLength = (U32)((ip - prefixLowest) + (dictEnd - dictLowest));
|
||||||
@@ -812,7 +814,7 @@ ZSTD_compressBlock_lazy_generic(
|
|||||||
if (offset_2 > maxRep) savedOffset = offset_2, offset_2 = 0;
|
if (offset_2 > maxRep) savedOffset = offset_2, offset_2 = 0;
|
||||||
if (offset_1 > maxRep) savedOffset = offset_1, offset_1 = 0;
|
if (offset_1 > maxRep) savedOffset = offset_1, offset_1 = 0;
|
||||||
}
|
}
|
||||||
if (dictMode == ZSTD_dictMatchState || dictMode == ZSTD_dedicatedDictSearch) {
|
if (isDMS || isDDS) {
|
||||||
/* dictMatchState repCode checks don't currently handle repCode == 0
|
/* dictMatchState repCode checks don't currently handle repCode == 0
|
||||||
* disabling. */
|
* disabling. */
|
||||||
assert(offset_1 <= dictAndPrefixLength);
|
assert(offset_1 <= dictAndPrefixLength);
|
||||||
@@ -832,7 +834,7 @@ ZSTD_compressBlock_lazy_generic(
|
|||||||
const BYTE* start=ip+1;
|
const BYTE* start=ip+1;
|
||||||
|
|
||||||
/* check repCode */
|
/* check repCode */
|
||||||
if (dictMode == ZSTD_dictMatchState || dictMode == ZSTD_dedicatedDictSearch) {
|
if (isDMS || isDDS) {
|
||||||
const U32 repIndex = (U32)(ip - base) + 1 - offset_1;
|
const U32 repIndex = (U32)(ip - base) + 1 - offset_1;
|
||||||
const BYTE* repMatch = ((dictMode == ZSTD_dictMatchState || dictMode == ZSTD_dedicatedDictSearch)
|
const BYTE* repMatch = ((dictMode == ZSTD_dictMatchState || dictMode == ZSTD_dedicatedDictSearch)
|
||||||
&& repIndex < prefixLowestIndex) ?
|
&& repIndex < prefixLowestIndex) ?
|
||||||
@@ -875,7 +877,7 @@ ZSTD_compressBlock_lazy_generic(
|
|||||||
if ((mlRep >= 4) && (gain2 > gain1))
|
if ((mlRep >= 4) && (gain2 > gain1))
|
||||||
matchLength = mlRep, offset = 0, start = ip;
|
matchLength = mlRep, offset = 0, start = ip;
|
||||||
}
|
}
|
||||||
if (dictMode == ZSTD_dictMatchState || dictMode == ZSTD_dedicatedDictSearch) {
|
if (isDMS || isDDS) {
|
||||||
const U32 repIndex = (U32)(ip - base) - offset_1;
|
const U32 repIndex = (U32)(ip - base) - offset_1;
|
||||||
const BYTE* repMatch = repIndex < prefixLowestIndex ?
|
const BYTE* repMatch = repIndex < prefixLowestIndex ?
|
||||||
dictBase + (repIndex - dictIndexDelta) :
|
dictBase + (repIndex - dictIndexDelta) :
|
||||||
@@ -910,7 +912,7 @@ ZSTD_compressBlock_lazy_generic(
|
|||||||
if ((mlRep >= 4) && (gain2 > gain1))
|
if ((mlRep >= 4) && (gain2 > gain1))
|
||||||
matchLength = mlRep, offset = 0, start = ip;
|
matchLength = mlRep, offset = 0, start = ip;
|
||||||
}
|
}
|
||||||
if (dictMode == ZSTD_dictMatchState || dictMode == ZSTD_dedicatedDictSearch) {
|
if (isDMS || isDDS) {
|
||||||
const U32 repIndex = (U32)(ip - base) - offset_1;
|
const U32 repIndex = (U32)(ip - base) - offset_1;
|
||||||
const BYTE* repMatch = repIndex < prefixLowestIndex ?
|
const BYTE* repMatch = repIndex < prefixLowestIndex ?
|
||||||
dictBase + (repIndex - dictIndexDelta) :
|
dictBase + (repIndex - dictIndexDelta) :
|
||||||
@@ -948,7 +950,7 @@ ZSTD_compressBlock_lazy_generic(
|
|||||||
&& (start[-1] == (start-(offset-ZSTD_REP_MOVE))[-1]) ) /* only search for offset within prefix */
|
&& (start[-1] == (start-(offset-ZSTD_REP_MOVE))[-1]) ) /* only search for offset within prefix */
|
||||||
{ start--; matchLength++; }
|
{ start--; matchLength++; }
|
||||||
}
|
}
|
||||||
if (dictMode == ZSTD_dictMatchState || dictMode == ZSTD_dedicatedDictSearch) {
|
if (isDMS || isDDS) {
|
||||||
U32 const matchIndex = (U32)((start-base) - (offset - ZSTD_REP_MOVE));
|
U32 const matchIndex = (U32)((start-base) - (offset - ZSTD_REP_MOVE));
|
||||||
const BYTE* match = (matchIndex < prefixLowestIndex) ? dictBase + matchIndex - dictIndexDelta : base + matchIndex;
|
const BYTE* match = (matchIndex < prefixLowestIndex) ? dictBase + matchIndex - dictIndexDelta : base + matchIndex;
|
||||||
const BYTE* const mStart = (matchIndex < prefixLowestIndex) ? dictLowest : prefixLowest;
|
const BYTE* const mStart = (matchIndex < prefixLowestIndex) ? dictLowest : prefixLowest;
|
||||||
@@ -964,12 +966,11 @@ _storeSequence:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check immediate repcode */
|
/* check immediate repcode */
|
||||||
if (dictMode == ZSTD_dictMatchState || dictMode == ZSTD_dedicatedDictSearch) {
|
if (isDMS || isDDS) {
|
||||||
while (ip <= ilimit) {
|
while (ip <= ilimit) {
|
||||||
U32 const current2 = (U32)(ip-base);
|
U32 const current2 = (U32)(ip-base);
|
||||||
U32 const repIndex = current2 - offset_2;
|
U32 const repIndex = current2 - offset_2;
|
||||||
const BYTE* repMatch = (dictMode == ZSTD_dictMatchState || dictMode == ZSTD_dedicatedDictSearch)
|
const BYTE* repMatch = repIndex < prefixLowestIndex ?
|
||||||
&& repIndex < prefixLowestIndex ?
|
|
||||||
dictBase - dictIndexDelta + repIndex :
|
dictBase - dictIndexDelta + repIndex :
|
||||||
base + repIndex;
|
base + repIndex;
|
||||||
if ( ((U32)((prefixLowestIndex-1) - (U32)repIndex) >= 3 /* intentional overflow */)
|
if ( ((U32)((prefixLowestIndex-1) - (U32)repIndex) >= 3 /* intentional overflow */)
|
||||||
|
|||||||
Reference in New Issue
Block a user