Skip to content

Commit

Permalink
findResourceWriters often creates HashSets and ArrayLists while not n…
Browse files Browse the repository at this point in the history
…ecessary
  • Loading branch information
franz1981 committed Jun 29, 2023
1 parent b61ceea commit 5f8c7f1
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ protected List<ResourceWriter> findResourceWriters(QuarkusMultivaluedMap<Class<?
List<ResourceWriter> ret = new ArrayList<>();
Deque<Class<?>> toProcess = new LinkedList<>();
do {
if (currentClass == Object.class) {
if (currentClass == Object.class && !toProcess.isEmpty()) {
//spec extension, look for interfaces as well
//we match interfaces before Object
Set<Class<?>> seen = new HashSet<>(toProcess);
Expand All @@ -182,13 +182,16 @@ protected List<ResourceWriter> findResourceWriters(QuarkusMultivaluedMap<Class<?
}
List<ResourceWriter> goodTypeWriters = writers.get(currentClass);
writerLookup(runtimeType, produces, desired, ret, goodTypeWriters);
toProcess.addAll(Arrays.asList(currentClass.getInterfaces()));
var prevClass = currentClass;
// if we're an interface, pretend our superclass is Object to get us through the same logic as a class
if (currentClass.isInterface()) {
currentClass = Object.class;
} else {
currentClass = currentClass.getSuperclass();
}
if (currentClass != null) {
toProcess.addAll(List.of(prevClass.getInterfaces()));
}
} while (currentClass != null);

return ret;
Expand Down

0 comments on commit 5f8c7f1

Please sign in to comment.