This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/openwebbeans.git
The following commit(s) were added to refs/heads/main by this push:
new aa59630b4 OWB-1463 remove nested for loop resulting in a O(^2)
aa59630b4 is described below
commit aa59630b4458f8aff9d50c375279935e45f69a02
Author: Mark Struberg <[email protected]>
AuthorDate: Sat Jul 4 17:32:49 2026 +0200
OWB-1463 remove nested for loop resulting in a O(^2)
This change is a performance improvement and related to OWB-1298.
---
.../org/apache/webbeans/config/BeansDeployer.java | 9 +-------
.../apache/webbeans/container/BeanManagerImpl.java | 25 ++++++++++++++++++++++
2 files changed, 26 insertions(+), 8 deletions(-)
diff --git
a/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
b/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
index 34a03a675..94f5350ac 100644
--- a/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
+++ b/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
@@ -39,7 +39,6 @@ import
org.apache.webbeans.component.creation.ObserverMethodsBuilder;
import org.apache.webbeans.component.creation.ProducerFieldBeansBuilder;
import org.apache.webbeans.component.creation.ProducerMethodBeansBuilder;
import org.apache.webbeans.configurator.AnnotatedTypeConfiguratorImpl;
-import org.apache.webbeans.container.AnnotatedTypeWrapper;
import org.apache.webbeans.container.BeanManagerImpl;
import org.apache.webbeans.container.InjectableBeanManager;
import org.apache.webbeans.container.InjectionResolver;
@@ -1631,14 +1630,8 @@ public class BeansDeployer
for (Map.Entry<AnnotatedType<?>, ExtendedBeanAttributes<?>>
annotatedType : beanAttributesMap.entrySet())
{
final AnnotatedType<?> key = annotatedType.getKey();
- final Collection<? extends AnnotatedType<?>>
userAnnotatedTypes =
- bm.getUserAnnotatedTypes(key.getJavaClass());
// if we have a matching AT (same type+annotations+default id)
we skip it since we already deployed it
- if (userAnnotatedTypes != null &&
userAnnotatedTypes.stream().anyMatch(it ->
- it != key &&
- AnnotatedTypeWrapper.class.isInstance(it) &&
-
AnnotatedTypeWrapper.class.cast(it).getId().endsWith(AnnotatedElementFactory.OWB_DEFAULT_KEY)
&&
- it.getAnnotations().equals(key.getAnnotations()))) //
strictly it is qualifiers only but faster
+ if (bm.hasAdditionalDefaultAnnotatedType(key))
{
continue;
}
diff --git
a/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
b/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
index d2c140749..5d402c762 100644
---
a/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
+++
b/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
@@ -1577,6 +1577,31 @@ public class BeanManagerImpl implements BeanManager,
Referenceable
return null;
}
+ public boolean hasAdditionalDefaultAnnotatedType(AnnotatedType<?>
annotatedType)
+ {
+ final ConcurrentMap<String, AnnotatedType<?>> annotatedTypes =
additionalAnnotatedTypes.get(annotatedType.getJavaClass());
+ if (annotatedTypes == null)
+ {
+ return false;
+ }
+
+ for (AnnotatedType<?> candidate : annotatedTypes.values())
+ {
+ if (candidate == annotatedType || !(candidate instanceof
AnnotatedTypeWrapper))
+ {
+ continue;
+ }
+
+ AnnotatedTypeWrapper<?> wrapper = (AnnotatedTypeWrapper<?>)
candidate;
+ if
(wrapper.getId().endsWith(AnnotatedElementFactory.OWB_DEFAULT_KEY) &&
+
candidate.getAnnotations().equals(annotatedType.getAnnotations())) // strictly
it is qualifiers only but faster
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
public <T> Iterable<AnnotatedType<T>> getAnnotatedTypes(Class<T> type)
{
final Collection<AnnotatedType<T>> types = new ArrayList<>(2);