From: W. Felix Handte Date: Wed, 8 Sep 2021 16:45:42 +0000 (-0400) Subject: Write Back Advanced Hash in Long Matches as Well (+Ratio) X-Git-Tag: v1.5.1~1^2~77^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ddef7c872c123383aa8b998a3b428bf359a8ce0;p=thirdparty%2Fzstd.git Write Back Advanced Hash in Long Matches as Well (+Ratio) Since we're now hashing the position ahead even if we find a long match and don't search that next position, we can write it back into the hashtable even in long matches. This seems to cost us no speed, and improves compression ratio slightly! --- diff --git a/lib/compress/zstd_double_fast.c b/lib/compress/zstd_double_fast.c index 45770b886..2e310e322 100644 --- a/lib/compress/zstd_double_fast.c +++ b/lib/compress/zstd_double_fast.c @@ -204,6 +204,12 @@ _search_next_long: while (((ip>anchor) & (matchs0>prefixLowest)) && (ip[-1] == matchs0[-1])) { ip--; matchs0--; mLength++; } /* catch up */ } + /* fall-through */ + +_match_found: /* requires ip, offset, mLength */ + offset_2 = offset_1; + offset_1 = offset; + if (step < 4) { /* It is unsafe to write this value back to the hashtable when ip1 is * greater than or equal to the new ip we will have after we're done @@ -215,12 +221,6 @@ _search_next_long: hashLong[hl1] = (U32)(ip1 - base); } - /* fall-through */ - -_match_found: /* requires ip, offset, mLength */ - offset_2 = offset_1; - offset_1 = offset; - ZSTD_storeSeq(seqStore, (size_t)(ip-anchor), anchor, iend, offset + ZSTD_REP_MOVE, mLength-MINMATCH); _match_stored: