Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OverlappingFieldsCanBeMergedRule: futher simplify 'PairSet' #3108

Merged
merged 1 commit into from May 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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