From ed9304eb255c101029dfb96e664c2fb20fa001b8 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Mon, 17 May 2021 14:01:39 +0300 Subject: [PATCH] OverlappingFieldsCanBeMergedRule: futher simplify 'PairSet' --- .../rules/OverlappingFieldsCanBeMergedRule.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/validation/rules/OverlappingFieldsCanBeMergedRule.js b/src/validation/rules/OverlappingFieldsCanBeMergedRule.js index 8f7281cd7d..a203b0abef 100644 --- a/src/validation/rules/OverlappingFieldsCanBeMergedRule.js +++ b/src/validation/rules/OverlappingFieldsCanBeMergedRule.js @@ -781,8 +781,7 @@ function subfieldConflicts( } /** - * A way to keep track of pairs of things when the ordering of the pair does - * not matter. We do this by maintaining a sort of double adjacency sets. + * A way to keep track of pairs of things when the ordering of the pair does not matter. */ class PairSet { _data: Map>; @@ -798,13 +797,11 @@ class PairSet { if (result === undefined) { return false; } - // areMutuallyExclusive being false is a superset of being true, - // hence if we want to know if this PairSet "has" these two with no - // exclusivity, we have to ensure it was added as such. - if (areMutuallyExclusive === false) { - return result === false; - } - return true; + + // areMutuallyExclusive being false is a superset of being true, hence if + // we want to know if this PairSet "has" these two with no exclusivity, + // we have to ensure it was added as such. + return areMutuallyExclusive ? true : areMutuallyExclusive === result; } add(a: string, b: string, areMutuallyExclusive: boolean): void {