From: senhuang42 Date: Thu, 8 Oct 2020 03:44:36 +0000 (-0400) Subject: Require LDM matches to be strictly greater in length X-Git-Tag: v1.4.7~57^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6911b86bea2132ffae3d3841d35c4215e6b4609;p=thirdparty%2Fzstd.git Require LDM matches to be strictly greater in length --- diff --git a/lib/compress/zstd_opt.c b/lib/compress/zstd_opt.c index 8ba7aba38..e55c459de 100644 --- a/lib/compress/zstd_opt.c +++ b/lib/compress/zstd_opt.c @@ -867,20 +867,9 @@ static void ZSTD_optLdm_maybeAddMatch(ZSTD_match_t* matches, U32* nbMatches, return; } - DEBUGLOG(6, "ZSTD_optLdm_maybeAddMatch(): Adding ldm candidate match (offCode: %u matchLength %u) at block position=%u", - candidateOffCode, candidateMatchLength, currPosInBlock); - if (*nbMatches == 0) { - matches[*nbMatches].len = candidateMatchLength; - matches[*nbMatches].off = candidateOffCode; - (*nbMatches)++; - } else if ((candidateMatchLength >= matches[*nbMatches-1].len) && *nbMatches < ZSTD_OPT_NUM) { - if (candidateMatchLength == matches[*nbMatches-1].len) { - /* No need to insert match with same matchLength. At most, replace offCode if it is smaller. */ - if (candidateOffCode < matches[*nbMatches-1].off) { - matches[*nbMatches-1].off = candidateOffCode; - } - return; - } + if (*nbMatches == 0 || ((candidateMatchLength > matches[*nbMatches-1].len) && *nbMatches < ZSTD_OPT_NUM)) { + DEBUGLOG(6, "ZSTD_optLdm_maybeAddMatch(): Adding ldm candidate match (offCode: %u matchLength %u) at block position=%u", + candidateOffCode, candidateMatchLength, currPosInBlock); matches[*nbMatches].len = candidateMatchLength; matches[*nbMatches].off = candidateOffCode; (*nbMatches)++;