From: senhuang42 Date: Wed, 30 Sep 2020 16:54:45 +0000 (-0400) Subject: Prevent duplicate LDMs from being inserted X-Git-Tag: v1.4.7~57^2~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4793ae3b8429dbd1d59410a62df0dff0990f6861;p=thirdparty%2Fzstd.git Prevent duplicate LDMs from being inserted --- diff --git a/lib/compress/zstd_opt.c b/lib/compress/zstd_opt.c index d6c728462..088282ca2 100644 --- a/lib/compress/zstd_opt.c +++ b/lib/compress/zstd_opt.c @@ -868,6 +868,10 @@ static void ldm_maybeAddLdm(ZSTD_match_t* matches, U32* nbMatches, * the ldm match down as necessary. */ if (candidateMatchLength == matches[*nbMatches-1].len) { + if (candidateOffCode == matches[*nbMatches-1].off) { + /* No need to insert the match if it's the exact same */ + return; + } U32 candidateMatchIdx = *nbMatches; matches[*nbMatches].len = candidateMatchLength; matches[*nbMatches].off = candidateOffCode;