Skip to content

Commit c6a6fb4

Browse files
committed
Avoid initializing getObserverAndProducerMethods() for every call
1 parent 50f0ebf commit c6a6fb4

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanDeployment.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public class BeanDeployment {
8989
private final List<DecoratorInfo> decorators;
9090

9191
private final List<ObserverInfo> observers;
92+
private Set<MethodInfo> observerAndProducerMethods;
9293

9394
private final Set<InvokerInfo> invokers;
9495

@@ -317,6 +318,8 @@ void init(Consumer<BytecodeTransformer> bytecodeTransformerConsumer,
317318
List<Predicate<BeanInfo>> additionalUnusedBeanExclusions) {
318319
long start = System.nanoTime();
319320

321+
initObserverAndProducerMethods(observers, beans);
322+
320323
// Collect dependency resolution errors
321324
List<Throwable> errors = new ArrayList<>();
322325
for (BeanInfo bean : beans) {
@@ -789,6 +792,15 @@ Integer computeAlternativePriority(AnnotationTarget target, List<StereotypeInfo>
789792
}
790793

791794
Set<MethodInfo> getObserverAndProducerMethods() {
795+
if (observerAndProducerMethods == null) {
796+
throw new IllegalStateException(
797+
"getObserverAndProducerMethods() has been called but observerAndProducerMethods has not been initialized yet");
798+
}
799+
800+
return observerAndProducerMethods;
801+
}
802+
803+
private void initObserverAndProducerMethods(List<ObserverInfo> observers, List<BeanInfo> beans) {
792804
Set<MethodInfo> ret = new HashSet<>();
793805
for (ObserverInfo observer : observers) {
794806
if (!observer.isSynthetic()) {
@@ -800,7 +812,8 @@ Set<MethodInfo> getObserverAndProducerMethods() {
800812
ret.add(bean.getTarget().get().asMethod());
801813
}
802814
}
803-
return ret;
815+
816+
observerAndProducerMethods = Collections.unmodifiableSet(ret);
804817
}
805818

806819
private boolean isRuntimeAnnotationType(ClassInfo annotationType) {

0 commit comments

Comments
 (0)