Simplify code in NioEndpoint$Poller.
authorkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 21 Sep 2011 13:14:29 +0000 (13:14 +0000)
committerkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 21 Sep 2011 13:14:29 +0000 (13:14 +0000)
The events.size() call is costly, because it is a loop that counts entries in a linked queue.
Actually it is not needed here at all, because we iterate the queue by ourselves.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1173614 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/tomcat/util/net/NioEndpoint.java

index e5e59f9..6138ba6 100644 (file)
@@ -970,13 +970,19 @@ public class NioEndpoint extends AbstractEndpoint {
             else r.reset(socket,null,interestOps);
             addEvent(r);
         }
-        
+
+        /**
+         * Processes events in the event queue of the Poller.
+         * 
+         * @return <code>true</code> if some events were processed,
+         *   <code>false</code> if queue was empty
+         */
         public boolean events() {
             boolean result = false;
 
             Runnable r = null;
-            result = (events.size() > 0);
             while ( (r = events.poll()) != null ) {
+                result = true;
                 try {
                     r.run();
                     if ( r instanceof PollerEvent ) {