Skip to content

Commit 60d5a0a

Browse files
committed
Optimize GraphQLUnionType.isPossibleType
Remove the allocation overhead of the stream / lambda in isPossibleType.
1 parent a04e677 commit 60d5a0a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/java/graphql/schema/GraphQLUnionType.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@ public List<GraphQLNamedOutputType> getTypes() {
9696
* @return true if the object type is a member of this union type.
9797
*/
9898
public boolean isPossibleType(GraphQLObjectType graphQLObjectType) {
99-
return getTypes().stream().anyMatch(nt -> nt.getName().equals(graphQLObjectType.getName()));
99+
for (GraphQLNamedOutputType type : getTypes()) {
100+
if (type.getName().equals(graphQLObjectType.getName())) {
101+
return true;
102+
}
103+
}
104+
return false;
100105
}
101106

102107
// to be removed in a future version when all code is in the code registry

0 commit comments

Comments
 (0)