Pull Match Found Stuff Out of the Loop
This commit is contained in:
@@ -60,7 +60,6 @@ size_t ZSTD_compressBlock_doubleFast_singleSegment_generic(
|
|||||||
const U32 hBitsS = cParams->chainLog;
|
const U32 hBitsS = cParams->chainLog;
|
||||||
const BYTE* const base = ms->window.base;
|
const BYTE* const base = ms->window.base;
|
||||||
const BYTE* const istart = (const BYTE*)src;
|
const BYTE* const istart = (const BYTE*)src;
|
||||||
const BYTE* ip = istart;
|
|
||||||
const BYTE* anchor = istart;
|
const BYTE* anchor = istart;
|
||||||
const U32 endIndex = (U32)((size_t)(istart - base) + srcSize);
|
const U32 endIndex = (U32)((size_t)(istart - base) + srcSize);
|
||||||
/* presumes that, if there is a dictionary, it must be using Attach mode */
|
/* presumes that, if there is a dictionary, it must be using Attach mode */
|
||||||
@@ -70,9 +69,14 @@ size_t ZSTD_compressBlock_doubleFast_singleSegment_generic(
|
|||||||
const BYTE* const ilimit = iend - HASH_READ_SIZE;
|
const BYTE* const ilimit = iend - HASH_READ_SIZE;
|
||||||
U32 offset_1=rep[0], offset_2=rep[1];
|
U32 offset_1=rep[0], offset_2=rep[1];
|
||||||
U32 offsetSaved = 0;
|
U32 offsetSaved = 0;
|
||||||
size_t step = 1;
|
|
||||||
|
size_t mLength;
|
||||||
|
U32 offset;
|
||||||
|
U32 curr;
|
||||||
|
|
||||||
const size_t kStepIncr = 1 << kSearchStrength;
|
const size_t kStepIncr = 1 << kSearchStrength;
|
||||||
const BYTE* nextStep = ip + kStepIncr;
|
const BYTE* nextStep;
|
||||||
|
size_t step;
|
||||||
|
|
||||||
size_t hl0;
|
size_t hl0;
|
||||||
size_t hs0;
|
size_t hs0;
|
||||||
@@ -89,23 +93,34 @@ size_t ZSTD_compressBlock_doubleFast_singleSegment_generic(
|
|||||||
const BYTE* matchl1;
|
const BYTE* matchl1;
|
||||||
// const BYTE* matchs1;
|
// const BYTE* matchs1;
|
||||||
|
|
||||||
|
const BYTE* ip = istart;
|
||||||
|
const BYTE* ip1;
|
||||||
|
|
||||||
DEBUGLOG(5, "ZSTD_compressBlock_doubleFast_singleSegment_generic");
|
DEBUGLOG(5, "ZSTD_compressBlock_doubleFast_singleSegment_generic");
|
||||||
|
|
||||||
/* init */
|
/* init */
|
||||||
ip += ((ip - prefixLowest) == 0);
|
ip += ((ip - prefixLowest) == 0);
|
||||||
{
|
{
|
||||||
U32 const curr = (U32)(ip - base);
|
U32 const current = (U32)(ip - base);
|
||||||
U32 const windowLow = ZSTD_getLowestPrefixIndex(ms, curr, cParams->windowLog);
|
U32 const windowLow = ZSTD_getLowestPrefixIndex(ms, current, cParams->windowLog);
|
||||||
U32 const maxRep = curr - windowLow;
|
U32 const maxRep = current - windowLow;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_start:
|
||||||
|
|
||||||
|
step = 1;
|
||||||
|
nextStep = ip + kStepIncr;
|
||||||
|
ip1 = ip + step;
|
||||||
|
|
||||||
|
if (ip1 >= ilimit) {
|
||||||
|
goto _cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
/* Main Search Loop */
|
/* Main Search Loop */
|
||||||
while (ip < ilimit) { /* < instead of <=, because repcode check at (ip+1) */
|
do {
|
||||||
size_t mLength;
|
curr = (U32)(ip-base);
|
||||||
U32 offset;
|
|
||||||
U32 const curr = (U32)(ip-base);
|
|
||||||
hl0 = ZSTD_hashPtr(ip, hBitsL, 8);
|
hl0 = ZSTD_hashPtr(ip, hBitsL, 8);
|
||||||
hs0 = ZSTD_hashPtr(ip, hBitsS, mls);
|
hs0 = ZSTD_hashPtr(ip, hBitsS, mls);
|
||||||
idxl0 = hashLong[hl0];
|
idxl0 = hashLong[hl0];
|
||||||
@@ -151,10 +166,17 @@ size_t ZSTD_compressBlock_doubleFast_singleSegment_generic(
|
|||||||
#if defined(__aarch64__)
|
#if defined(__aarch64__)
|
||||||
PREFETCH_L1(ip+256);
|
PREFETCH_L1(ip+256);
|
||||||
#endif
|
#endif
|
||||||
continue;
|
} while (ip < ilimit);
|
||||||
|
|
||||||
|
_cleanup:
|
||||||
|
/* save reps for next block */
|
||||||
|
rep[0] = offset_1 ? offset_1 : offsetSaved;
|
||||||
|
rep[1] = offset_2 ? offset_2 : offsetSaved;
|
||||||
|
|
||||||
|
/* Return the last literals size */
|
||||||
|
return (size_t)(iend - anchor);
|
||||||
|
|
||||||
_search_next_long:
|
_search_next_long:
|
||||||
|
|
||||||
{ hl1 = ZSTD_hashPtr(ip+1, hBitsL, 8);
|
{ hl1 = ZSTD_hashPtr(ip+1, hBitsL, 8);
|
||||||
idxl1 = hashLong[hl1];
|
idxl1 = hashLong[hl1];
|
||||||
matchl1 = base + idxl1;
|
matchl1 = base + idxl1;
|
||||||
@@ -217,16 +239,7 @@ _match_stored:
|
|||||||
continue; /* faster when present ... (?) */
|
continue; /* faster when present ... (?) */
|
||||||
} }
|
} }
|
||||||
|
|
||||||
step = 1;
|
goto _start;
|
||||||
nextStep = ip + kStepIncr;
|
|
||||||
} /* while (ip < ilimit) */
|
|
||||||
|
|
||||||
/* save reps for next block */
|
|
||||||
rep[0] = offset_1 ? offset_1 : offsetSaved;
|
|
||||||
rep[1] = offset_2 ? offset_2 : offsetSaved;
|
|
||||||
|
|
||||||
/* Return the last literals size */
|
|
||||||
return (size_t)(iend - anchor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user