Track Step Size Statefully, Rather than Recalculating Every Time

This commit is contained in:
W. Felix Handte 2021-08-18 12:47:14 -04:00
parent 80bc12b33a
commit bc768bccc0

View File

@ -268,6 +268,10 @@ ZSTD_compressBlock_fast_generic_pipelined(
const BYTE* match0; const BYTE* match0;
size_t mLength; size_t mLength;
size_t step;
const BYTE* nextStep;
const size_t kStepIncr = (1 << (kSearchStrength - 1));
DEBUGLOG(5, "ZSTD_compressBlock_fast_generic_pipelined"); DEBUGLOG(5, "ZSTD_compressBlock_fast_generic_pipelined");
ip0 += (ip0 == prefixStart); ip0 += (ip0 == prefixStart);
{ U32 const curr = (U32)(ip0 - base); { U32 const curr = (U32)(ip0 - base);
@ -280,6 +284,9 @@ ZSTD_compressBlock_fast_generic_pipelined(
/* start each op */ /* start each op */
_start: /* Requires: ip0 */ _start: /* Requires: ip0 */
step = stepSize;
nextStep = ip0 + kStepIncr;
/* calculate positions, ip0 - anchor == 0, so we skip step calc */ /* calculate positions, ip0 - anchor == 0, so we skip step calc */
ip1 = ip0 + stepSize; ip1 = ip0 + stepSize;
ip2 = ip1 + stepSize; ip2 = ip1 + stepSize;
@ -348,8 +355,10 @@ _start: /* Requires: ip0 */
/* advance to next positions */ /* advance to next positions */
{ {
size_t const step = ((size_t)(ip2 - anchor) >> (kSearchStrength - 1)) + stepSize; if (ip2 >= nextStep) {
assert(step >= 1); step++;
nextStep += kStepIncr;
}
idx0 = idx1; idx0 = idx1;
idx1 = idx2; idx1 = idx2;