From 4793ae3b8429dbd1d59410a62df0dff0990f6861 Mon Sep 17 00:00:00 2001 From: senhuang42 Date: Wed, 30 Sep 2020 12:54:45 -0400 Subject: [PATCH] Prevent duplicate LDMs from being inserted --- lib/compress/zstd_opt.c | 4 ++++ 1 file changed, 4 insertions(+) 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;