From: W. Felix Handte Date: Wed, 16 May 2018 19:20:16 +0000 (-0400) Subject: Interleave Prefix and Dict Searches X-Git-Tag: v1.3.5~3^2~37^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88b733b380c99f0952d7ff2ea8ac6248b24a6a5a;p=thirdparty%2Fzstd.git Interleave Prefix and Dict Searches --- diff --git a/lib/compress/zstd_double_fast.c b/lib/compress/zstd_double_fast.c index de1529006..cf58da161 100644 --- a/lib/compress/zstd_double_fast.c +++ b/lib/compress/zstd_double_fast.c @@ -149,6 +149,20 @@ size_t ZSTD_compressBlock_doubleFast_generic( goto _match_found; } + /* check dictMatchState long match */ + if (dictMode == ZSTD_dictMatchState) { + U32 const dictMatchIndexL = dictHashLong[h2]; + const BYTE* dictMatchL = dictBase + dictMatchIndexL; + assert(dictMatchL < dictEnd); + + if (dictMatchL > dictLowest && MEM_read64(dictMatchL) == MEM_read64(ip)) { + mLength = ZSTD_count_2segments(ip+8, dictMatchL+8, iend, dictEnd, prefixLowest) + 8; + offset = (U32)(current - dictMatchIndexL - dictIndexDelta); + while (((ip>anchor) & (dictMatchL>dictLowest)) && (ip[-1] == dictMatchL[-1])) { ip--; dictMatchL--; mLength++; } /* catch up */ + goto _match_found; + } + } + /* check prefix short match */ if ( (matchIndexS > prefixLowestIndex) && (MEM_read32(match) == MEM_read32(ip)) ) { size_t const hl3 = ZSTD_hashPtr(ip+1, hBitsL, 8); @@ -170,22 +184,12 @@ size_t ZSTD_compressBlock_doubleFast_generic( goto _match_found; } - /* check dictMatchState matches */ + /* check dictMatchState short match */ if (dictMode == ZSTD_dictMatchState) { - U32 const dictMatchIndexL = dictHashLong[h2]; U32 const dictMatchIndexS = dictHashSmall[h]; - const BYTE* dictMatchL = dictBase + dictMatchIndexL; const BYTE* dictMatchS = dictBase + dictMatchIndexS; - assert(dictMatchL < dictEnd); assert(dictMatchS < dictEnd); - if (dictMatchL > dictLowest && MEM_read64(dictMatchL) == MEM_read64(ip)) { - mLength = ZSTD_count_2segments(ip+8, dictMatchL+8, iend, dictEnd, prefixLowest) + 8; - offset = (U32)(current - dictMatchIndexL - dictIndexDelta); - while (((ip>anchor) & (dictMatchL>dictLowest)) && (ip[-1] == dictMatchL[-1])) { ip--; dictMatchL--; mLength++; } /* catch up */ - goto _match_found; - } - if (dictMatchS > dictLowest && MEM_read32(dictMatchS) == MEM_read32(ip)) { size_t const hl3 = ZSTD_hashPtr(ip+1, hBitsL, 8); U32 const dictMatchIndexL3 = dictHashLong[hl3];