openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1830469 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/event/ test/java/org/apache/webbeans/test/events/observer/
Date Sat, 28 Apr 2018 19:31:31 GMT
Author: struberg
Date: Sat Apr 28 19:31:31 2018
New Revision: 1830469

URL: http://svn.apache.org/viewvc?rev=1830469&view=rev
Log:
OWB-1243 use fixed Comparator instead of Lambda

This is a tad faster as Comparator.comparingInt does lots
of useless checks an conversions internally.

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/observer/Litographer.java
      - copied, changed from r1830447, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/observer/Painter.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/observer/EventTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java?rev=1830469&r1=1830468&r2=1830469&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
Sat Apr 28 19:31:31 2018
@@ -140,6 +140,17 @@ public final class NotificationManager
             ProcessSyntheticAnnotatedType.class,
         }));
 
+    // this is actually faster than a lambda Comparator.comparingInt(ObserverMethod::getPriority)
+    private Comparator<? super ObserverMethod<? super Object>> observerMethodComparator
+        = new Comparator<ObserverMethod<? super Object>>()
+            {
+                @Override
+                public int compare(ObserverMethod<? super Object> o1, ObserverMethod<?
super Object> o2)
+                {
+                    return Integer.compare(o1.getPriority(), o2.getPriority());
+                }
+            };
+
     public NotificationManager(WebBeansContext webBeansContext)
     {
         this.webBeansContext = webBeansContext;
@@ -694,7 +705,7 @@ public final class NotificationManager
         // new in CDI-2.0: sort observers
         if (observerMethods.size() > 1)
         {
-            observerMethods.sort(Comparator.comparingInt(ObserverMethod::getPriority));
+            observerMethods.sort(observerMethodComparator);
         }
 
         List<CompletableFuture<Void>> completableFutures = async ? new ArrayList<>()
: null;

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/observer/EventTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/observer/EventTest.java?rev=1830469&r1=1830468&r2=1830469&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/observer/EventTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/observer/EventTest.java
Sat Apr 28 19:31:31 2018
@@ -157,9 +157,7 @@ public class EventTest extends AbstractU
     @Ignore("only for manual performance testing and debugging")
     public void testEventPerformance()
     {
-        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
-        beanClasses.add(Painter.class);
-        startContainer(beanClasses, null);
+        startContainer(Painter.class, Litographer.class);
 
         final Orange orange = new Orange();
 

Copied: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/observer/Litographer.java
(from r1830447, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/observer/Painter.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/observer/Litographer.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/observer/Litographer.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/observer/Painter.java&r1=1830447&r2=1830469&rev=1830469&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/observer/Painter.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/observer/Litographer.java
Sat Apr 28 19:31:31 2018
@@ -18,14 +18,14 @@
  */
 package org.apache.webbeans.test.events.observer;
 
-import java.util.ArrayList;
-import java.util.List;
-
 import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.event.Observes;
+import java.util.ArrayList;
+import java.util.List;
 
 @ApplicationScoped
-public class Painter {
+public class Litographer
+{
 
     private List<Object> observed = new ArrayList<Object>();
 



Mime
View raw message