Skip to content

Commit b460659

Browse files
authored
Use hashmap instead of array find
1 parent 8234f4e commit b460659

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/type/definition.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,18 +450,18 @@ function defineInterfaces(
450450
'an Array.'
451451
);
452452

453-
const seenInterfaceNames = [];
453+
const implementedTypeNames = {};
454454
interfaces.forEach(iface => {
455455
invariant(
456456
iface instanceof GraphQLInterfaceType,
457457
`${type.name} may only implement Interface types, it cannot ` +
458458
`implement: ${String(iface)}.`
459459
);
460460
invariant(
461-
seenInterfaceNames.indexOf(iface.name) === -1,
461+
!implementedTypeNames[iface.name],
462462
`${type.name} may declare it implements ${iface.name} only once.`
463463
);
464-
seenInterfaceNames.push(iface.name);
464+
implementedTypeNames[iface.name] = true;
465465
if (typeof iface.resolveType !== 'function') {
466466
invariant(
467467
typeof type.isTypeOf === 'function',

0 commit comments

Comments
 (0)