Mark, On 3/11/15 5:35 PM, [email protected] wrote: > Author: markt > Date: Wed Mar 11 21:35:39 2015 > New Revision: 1666017 > > URL: http://svn.apache.org/r1666017 > Log: > Implement the merging. > I opted for certain clarity over the possible speed improvement of a more > 'hands-on' implementation. > > Modified: > tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java > > Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java > URL: > http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=1666017&r1=1666016&r2=1666017&view=diff > ============================================================================== > --- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original) > +++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Wed Mar 11 > 21:35:39 2015 > @@ -1928,10 +1928,22 @@ public class AprEndpoint extends Abstrac > > private int mergeDescriptors(long[] desc, int startCount) { > if (OS.IS_BSD || OS.IS_MACOSX) {
You could avoid a check by installing a "DescriptorMerger" object that
is a no-op for non-BSD OSs if you wanted to avoid repeatedly-evaluated
conditional.
OS.IS_foo are all static final, though, so I expect the JIT to figure
that out eventually.
> - // TODO Need to actually implement merging of the
> descriptors here.
> - // I'm currently thinking quicksort followed by running
> - // through the sorted list to merge the events.
> - return startCount;
> + /*
> + * Notes: Only the first startCount * 2 elements of the array
> + * are populated.
> + * The array is event, socket, event, socket etc.
> + */
> + HashMap<Long,Long> merged = new HashMap<>(startCount);
> + for (int n = 0; n < startCount; n++) {
> + merged.merge(Long.valueOf(desc[2*n+1]),
> Long.valueOf(desc[2*n]),
I'm not sure what either javac or JIT will do with this, but you can
help it along a little bit:
for(...)
long l = n << 1;
merged.merge(Long.valueOf(l+1), Long.valueOf(l), ...)
-chris
signature.asc
Description: OpenPGP digital signature
