From 59ddb70345864041d6d44b90a7108f13074a581e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 23 Jun 2019 11:05:42 +0200 Subject: [PATCH] Fix: Make sure links are sorted and deduplicated --- lib/entry/libimagentrylink/src/linkable.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/entry/libimagentrylink/src/linkable.rs b/lib/entry/libimagentrylink/src/linkable.rs index e571a20f..104e6421 100644 --- a/lib/entry/libimagentrylink/src/linkable.rs +++ b/lib/entry/libimagentrylink/src/linkable.rs @@ -98,9 +98,15 @@ impl Linkable for Entry { let mut left_internal = left.internal.unwrap_or_else(|| vec![]); left_internal.push(right_location); + left_internal.sort_unstable(); + left_internal.dedup(); + let mut right_internal = right.internal.unwrap_or_else(|| vec![]); right_internal.push(left_location); + right_internal.sort_unstable(); + right_internal.dedup(); + left.internal = Some(left_internal); right.internal = Some(right_internal); @@ -117,9 +123,15 @@ impl Linkable for Entry { let mut left_internal = left.internal.unwrap_or_else(|| vec![]); left_internal.retain(|l| *l != right_location); + left_internal.sort_unstable(); + left_internal.dedup(); + let mut right_internal = right.internal.unwrap_or_else(|| vec![]); right_internal.retain(|l| *l != left_location); + right_internal.sort_unstable(); + right_internal.dedup(); + left.internal = Some(left_internal); right.internal = Some(right_internal);