From 3b65e7ea284bdcf49d25a6e91d050648ff622375 Mon Sep 17 00:00:00 2001 From: Scott Mitchell Date: Thu, 16 Feb 2017 08:05:48 -0800 Subject: [PATCH] EpollDatagramChannel avoid getOption Motivation: EpollDatagramChannel uses getOption in the isActive method. getOption is backed by a relatively large conditional if/else if block and this conditional checking can be avoided in the epoll transport. Modifications: - Add EpollDatagramChannelConfig#getActiveOnOpen and use this in EpollDatagramChannel Result: Conditional checking due to getOption is removed from EpollDatagramChannel. --- .../java/io/netty/channel/epoll/EpollDatagramChannel.java | 5 +---- .../io/netty/channel/epoll/EpollDatagramChannelConfig.java | 4 ++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollDatagramChannel.java b/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollDatagramChannel.java index 240df5f12d..5e4e7c434f 100644 --- a/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollDatagramChannel.java +++ b/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollDatagramChannel.java @@ -20,7 +20,6 @@ import io.netty.buffer.CompositeByteBuf; import io.netty.channel.AddressedEnvelope; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelMetadata; -import io.netty.channel.ChannelOption; import io.netty.channel.ChannelOutboundBuffer; import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelPromise; @@ -105,9 +104,7 @@ public final class EpollDatagramChannel extends AbstractEpollChannel implements @Override @SuppressWarnings("deprecation") public boolean isActive() { - return fd().isOpen() && - (config.getOption(ChannelOption.DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION) && isRegistered() - || active); + return fd().isOpen() && (config.getActiveOnOpen() && isRegistered() || active); } @Override diff --git a/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollDatagramChannelConfig.java b/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollDatagramChannelConfig.java index ab81180ec5..3228d56277 100644 --- a/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollDatagramChannelConfig.java +++ b/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollDatagramChannelConfig.java @@ -131,6 +131,10 @@ public final class EpollDatagramChannelConfig extends EpollChannelConfig impleme this.activeOnOpen = activeOnOpen; } + boolean getActiveOnOpen() { + return activeOnOpen; + } + @Override public EpollDatagramChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator) { super.setMessageSizeEstimator(estimator);