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

OverlappingFieldsCanBeMerged: remove excessive caching #2352

Merged
merged 1 commit into from
Jan 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions src/validation/rules/OverlappingFieldsCanBeMerged.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,11 @@ function findConflictsWithinSelectionSet(
if (fragmentNames.length !== 0) {
// (B) Then collect conflicts between these fields and those represented by
// each spread fragment name found.
const comparedFragments = Object.create(null);
for (let i = 0; i < fragmentNames.length; i++) {
collectConflictsBetweenFieldsAndFragment(
context,
conflicts,
cachedFieldsAndFragmentNames,
comparedFragments,
comparedFragmentPairs,
false,
fieldMap,
Expand Down Expand Up @@ -229,18 +227,11 @@ function collectConflictsBetweenFieldsAndFragment(
context: ValidationContext,
conflicts: Array<Conflict>,
cachedFieldsAndFragmentNames,
comparedFragments: ObjMap<boolean>,
comparedFragmentPairs: PairSet,
areMutuallyExclusive: boolean,
fieldMap: NodeAndDefCollection,
fragmentName: string,
): void {
// Memoize so a fragment is not compared for conflicts more than once.
if (comparedFragments[fragmentName]) {
return;
}
comparedFragments[fragmentName] = true;

const fragment = context.getFragment(fragmentName);
if (!fragment) {
return;
Expand Down Expand Up @@ -276,7 +267,6 @@ function collectConflictsBetweenFieldsAndFragment(
context,
conflicts,
cachedFieldsAndFragmentNames,
comparedFragments,
comparedFragmentPairs,
areMutuallyExclusive,
fieldMap,
Expand Down Expand Up @@ -413,13 +403,11 @@ function findConflictsBetweenSubSelectionSets(
// (I) Then collect conflicts between the first collection of fields and
// those referenced by each fragment name associated with the second.
if (fragmentNames2.length !== 0) {
const comparedFragments = Object.create(null);
for (let j = 0; j < fragmentNames2.length; j++) {
collectConflictsBetweenFieldsAndFragment(
context,
conflicts,
cachedFieldsAndFragmentNames,
comparedFragments,
comparedFragmentPairs,
areMutuallyExclusive,
fieldMap1,
Expand All @@ -431,13 +419,11 @@ function findConflictsBetweenSubSelectionSets(
// (I) Then collect conflicts between the second collection of fields and
// those referenced by each fragment name associated with the first.
if (fragmentNames1.length !== 0) {
const comparedFragments = Object.create(null);
for (let i = 0; i < fragmentNames1.length; i++) {
collectConflictsBetweenFieldsAndFragment(
context,
conflicts,
cachedFieldsAndFragmentNames,
comparedFragments,
comparedFragmentPairs,
areMutuallyExclusive,
fieldMap2,
Expand Down