]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Prevent duplicate LDMs from being inserted
authorsenhuang42 <senhuang96@fb.com>
Wed, 30 Sep 2020 16:54:45 +0000 (12:54 -0400)
committersenhuang42 <senhuang96@fb.com>
Wed, 7 Oct 2020 17:56:25 +0000 (13:56 -0400)
lib/compress/zstd_opt.c

index d6c728462cd79f2711156cfa3d168d871bfb9ab1..088282ca2345c168e0678ead4aed012b348710b4 100644 (file)
@@ -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;