Second Repcode Check

This commit is contained in:
W. Felix Handte 2018-05-23 15:49:43 -04:00
parent a2a24bebec
commit 3b82a23a35

View File

@ -640,16 +640,39 @@ _storeSequence:
} }
/* check immediate repcode */ /* check immediate repcode */
while ( ((ip <= ilimit) & (offset_2>0)) if (dictMode == ZSTD_dictMatchState) {
&& (MEM_read32(ip) == MEM_read32(ip - offset_2)) ) { while (ip <= ilimit) {
/* store sequence */ U32 const current2 = (U32)(ip-base);
matchLength = ZSTD_count(ip+4, ip+4-offset_2, iend) + 4; U32 const repIndex2 = current2 - offset_2;
offset = offset_2; offset_2 = offset_1; offset_1 = (U32)offset; /* swap repcodes */ const BYTE* repMatch2 = dictMode == ZSTD_dictMatchState
ZSTD_storeSeq(seqStore, 0, anchor, 0, matchLength-MINMATCH); && repIndex2 < prefixLowestIndex ?
ip += matchLength; dictBase - dictIndexDelta + repIndex2 :
anchor = ip; base + repIndex2;
continue; /* faster when present ... (?) */ if ( ((U32)((prefixLowestIndex-1) - (U32)repIndex2) >= 3 /* intentional overflow */)
} } && (MEM_read32(repMatch2) == MEM_read32(ip)) ) {
const BYTE* const repEnd2 = repIndex2 < prefixLowestIndex ? dictEnd : iend;
matchLength = ZSTD_count_2segments(ip+4, repMatch2+4, iend, repEnd2, istart) + 4;
offset = offset_2; offset_2 = offset_1; offset_1 = offset; /* swap offset_2 <=> offset_1 */
ZSTD_storeSeq(seqStore, 0, anchor, 0, matchLength-MINMATCH);
ip += matchLength;
anchor = ip;
continue;
}
break;
}
}
if (dictMode == ZSTD_noDict) {
while ( ((ip <= ilimit) & (offset_2>0))
&& (MEM_read32(ip) == MEM_read32(ip - offset_2)) ) {
/* store sequence */
matchLength = ZSTD_count(ip+4, ip+4-offset_2, iend) + 4;
offset = offset_2; offset_2 = offset_1; offset_1 = (U32)offset; /* swap repcodes */
ZSTD_storeSeq(seqStore, 0, anchor, 0, matchLength-MINMATCH);
ip += matchLength;
anchor = ip;
continue; /* faster when present ... (?) */
} } }
/* Save reps for next block */ /* Save reps for next block */
rep[0] = offset_1 ? offset_1 : savedOffset; rep[0] = offset_1 ? offset_1 : savedOffset;