From b8866aef330403353285486bbf5c0342b6c6a998 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Fri, 30 Aug 2013 06:31:58 +0200 Subject: [PATCH] No need to check instanceof everytime to find the next inbound / outbound context --- .../io/netty/channel/DefaultChannelHandlerContext.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java b/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java index 8f8fd8b363..6c4460833d 100644 --- a/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java +++ b/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java @@ -30,6 +30,8 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements volatile DefaultChannelHandlerContext next; volatile DefaultChannelHandlerContext prev; + private final boolean inbound; + private final boolean outbound; private final AbstractChannel channel; private final DefaultChannelPipeline pipeline; private final String name; @@ -74,6 +76,9 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements } else { executor = null; } + + inbound = handler instanceof ChannelInboundHandler; + outbound = handler instanceof ChannelOutboundHandler; } /** Invocation initiated by {@link DefaultChannelPipeline#teardownAll()}}. */ @@ -816,7 +821,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements DefaultChannelHandlerContext ctx = this; do { ctx = ctx.next; - } while (!(ctx.handler instanceof ChannelInboundHandler)); + } while (!ctx.inbound); return ctx; } @@ -824,7 +829,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements DefaultChannelHandlerContext ctx = this; do { ctx = ctx.prev; - } while (!(ctx.handler instanceof ChannelOutboundHandler)); + } while (!ctx.outbound); return ctx; }