Skip to content

Commit

Permalink
OverlappingFieldsCanBeMergedRule: futher simplify 'PairSet'
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed May 17, 2021
1 parent 9b0514a commit ed9304e
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/validation/rules/OverlappingFieldsCanBeMergedRule.js
Expand Up @@ -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<string, Map<string, boolean>>;
Expand All @@ -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 {
Expand Down

0 comments on commit ed9304e

Please sign in to comment.