Skip to content

Commit 8c7fe9d

Browse files
OverlappingFieldsCanBeMerged: remove excessive caching (#2352)
This caching is unneeded since fragment names are always collected into map and does contains duplicates, see: https://github.com/graphql/graphql-js/blob/6c377ac482e61b8179bb7dd0e44fa0ede8e1a91c/src/validation/rules/OverlappingFieldsCanBeMerged.js#L711
1 parent 0762193 commit 8c7fe9d

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

src/validation/rules/OverlappingFieldsCanBeMerged.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,11 @@ function findConflictsWithinSelectionSet(
191191
if (fragmentNames.length !== 0) {
192192
// (B) Then collect conflicts between these fields and those represented by
193193
// each spread fragment name found.
194-
const comparedFragments = Object.create(null);
195194
for (let i = 0; i < fragmentNames.length; i++) {
196195
collectConflictsBetweenFieldsAndFragment(
197196
context,
198197
conflicts,
199198
cachedFieldsAndFragmentNames,
200-
comparedFragments,
201199
comparedFragmentPairs,
202200
false,
203201
fieldMap,
@@ -229,18 +227,11 @@ function collectConflictsBetweenFieldsAndFragment(
229227
context: ValidationContext,
230228
conflicts: Array<Conflict>,
231229
cachedFieldsAndFragmentNames,
232-
comparedFragments: ObjMap<boolean>,
233230
comparedFragmentPairs: PairSet,
234231
areMutuallyExclusive: boolean,
235232
fieldMap: NodeAndDefCollection,
236233
fragmentName: string,
237234
): void {
238-
// Memoize so a fragment is not compared for conflicts more than once.
239-
if (comparedFragments[fragmentName]) {
240-
return;
241-
}
242-
comparedFragments[fragmentName] = true;
243-
244235
const fragment = context.getFragment(fragmentName);
245236
if (!fragment) {
246237
return;
@@ -276,7 +267,6 @@ function collectConflictsBetweenFieldsAndFragment(
276267
context,
277268
conflicts,
278269
cachedFieldsAndFragmentNames,
279-
comparedFragments,
280270
comparedFragmentPairs,
281271
areMutuallyExclusive,
282272
fieldMap,
@@ -413,13 +403,11 @@ function findConflictsBetweenSubSelectionSets(
413403
// (I) Then collect conflicts between the first collection of fields and
414404
// those referenced by each fragment name associated with the second.
415405
if (fragmentNames2.length !== 0) {
416-
const comparedFragments = Object.create(null);
417406
for (let j = 0; j < fragmentNames2.length; j++) {
418407
collectConflictsBetweenFieldsAndFragment(
419408
context,
420409
conflicts,
421410
cachedFieldsAndFragmentNames,
422-
comparedFragments,
423411
comparedFragmentPairs,
424412
areMutuallyExclusive,
425413
fieldMap1,
@@ -431,13 +419,11 @@ function findConflictsBetweenSubSelectionSets(
431419
// (I) Then collect conflicts between the second collection of fields and
432420
// those referenced by each fragment name associated with the first.
433421
if (fragmentNames1.length !== 0) {
434-
const comparedFragments = Object.create(null);
435422
for (let i = 0; i < fragmentNames1.length; i++) {
436423
collectConflictsBetweenFieldsAndFragment(
437424
context,
438425
conflicts,
439426
cachedFieldsAndFragmentNames,
440-
comparedFragments,
441427
comparedFragmentPairs,
442428
areMutuallyExclusive,
443429
fieldMap2,

0 commit comments

Comments
 (0)