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

Replace usage of Stack with Deque / ArrayDeque #2780

Merged
merged 1 commit into from Apr 3, 2022
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
11 changes: 5 additions & 6 deletions src/main/java/graphql/schema/idl/TypeInfo.java
Expand Up @@ -8,8 +8,9 @@
import graphql.language.TypeName;
import graphql.schema.GraphQLType;

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Objects;
import java.util.Stack;

import static graphql.Assert.assertNotNull;
import static graphql.schema.GraphQLList.list;
Expand All @@ -27,7 +28,7 @@ public static TypeInfo typeInfo(Type type) {

private final Type rawType;
private final TypeName typeName;
private final Stack<Class<?>> decoration = new Stack<>();
private final Deque<Class<?>> decoration = new ArrayDeque<>();

private TypeInfo(Type type) {
this.rawType = assertNotNull(type, () -> "type must not be null");
Expand Down Expand Up @@ -79,8 +80,7 @@ public TypeInfo renameAs(String newName) {

Type out = TypeName.newTypeName(newName).build();

Stack<Class<?>> wrappingStack = new Stack<>();
wrappingStack.addAll(this.decoration);
Deque<Class<?>> wrappingStack = new ArrayDeque<>(this.decoration);
while (!wrappingStack.isEmpty()) {
Class<?> clazz = wrappingStack.pop();
if (clazz.equals(NonNullType.class)) {
Expand All @@ -106,8 +106,7 @@ public TypeInfo renameAs(String newName) {
public <T extends GraphQLType> T decorate(GraphQLType objectType) {

GraphQLType out = objectType;
Stack<Class<?>> wrappingStack = new Stack<>();
wrappingStack.addAll(this.decoration);
Deque<Class<?>> wrappingStack = new ArrayDeque<>(this.decoration);
while (!wrappingStack.isEmpty()) {
Class<?> clazz = wrappingStack.pop();
if (clazz.equals(NonNullType.class)) {
Expand Down