Nit: Dedup idx0 and idx1

This commit is contained in:
W. Felix Handte
2021-09-01 14:15:04 -04:00
parent 7c24c3e6ce
commit 8706bc115a
+7 -10
View File
@@ -256,8 +256,7 @@ ZSTD_compressBlock_fast_generic_pipelined(
size_t hash0; /* hash for ip0 */ size_t hash0; /* hash for ip0 */
size_t hash1; /* hash for ip1 */ size_t hash1; /* hash for ip1 */
size_t hash2; /* hash for ip2 */ size_t hash2; /* hash for ip2 */
U32 idx0; /* match idx for ip0 */ U32 idx; /* match idx for ip0 */
U32 idx1; /* match idx for ip1 */
U32 mval; /* src value at match idx */ U32 mval; /* src value at match idx */
U32 offcode; U32 offcode;
@@ -294,7 +293,7 @@ _start: /* Requires: ip0 */
hash0 = ZSTD_hashPtr(ip0, hlog, mls); hash0 = ZSTD_hashPtr(ip0, hlog, mls);
hash1 = ZSTD_hashPtr(ip1, hlog, mls); hash1 = ZSTD_hashPtr(ip1, hlog, mls);
idx0 = hashTable[hash0]; idx = hashTable[hash0];
do { do {
const U32 rval = MEM_read32(ip2 - rep_offset1); const U32 rval = MEM_read32(ip2 - rep_offset1);
@@ -316,8 +315,8 @@ _start: /* Requires: ip0 */
} }
/* load match for ip[0] */ /* load match for ip[0] */
if (idx0 >= prefixStartIndex) { if (idx >= prefixStartIndex) {
mval = MEM_read32(base + idx0); mval = MEM_read32(base + idx);
} else { } else {
mval = MEM_read32(ip0) ^ 1; /* guaranteed to not match. */ mval = MEM_read32(ip0) ^ 1; /* guaranteed to not match. */
} }
@@ -332,7 +331,7 @@ _start: /* Requires: ip0 */
hash2 = ZSTD_hashPtr(ip2, hlog, mls); hash2 = ZSTD_hashPtr(ip2, hlog, mls);
/* lookup ip[1] */ /* lookup ip[1] */
idx1 = hashTable[hash1]; idx = hashTable[hash1];
/* advance to next positions */ /* advance to next positions */
{ {
@@ -342,8 +341,6 @@ _start: /* Requires: ip0 */
nextStep += kStepIncr; nextStep += kStepIncr;
} }
idx0 = idx1;
hash0 = hash1; hash0 = hash1;
hash1 = hash2; hash1 = hash2;
@@ -365,10 +362,10 @@ _cleanup:
/* Return the last literals size */ /* Return the last literals size */
return (size_t)(iend - anchor); return (size_t)(iend - anchor);
_offset: /* Requires: ip0, idx0 */ _offset: /* Requires: ip0, idx */
/* Compute the offset code. */ /* Compute the offset code. */
match0 = base + idx0; match0 = base + idx;
rep_offset2 = rep_offset1; rep_offset2 = rep_offset1;
rep_offset1 = (U32)(ip0-match0); rep_offset1 = (U32)(ip0-match0);
offcode = rep_offset1 + ZSTD_REP_MOVE; offcode = rep_offset1 + ZSTD_REP_MOVE;