Avoid unnecessary call to ByteBuf.isReadable() from ByteToMessageDecoder
Motivation: This will avoid one unncessary method invokation which will slightly improve performance. Modifications: Instead of calling isReadable we just check for the value of readableBytes() Result: Nothing functionally speaking change.
This commit is contained in:
parent
38015bffa7
commit
b8d26d1da3
@ -98,7 +98,7 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
|
||||
/**
|
||||
* Cumulate {@link ByteBuf}s by add them to a {@link CompositeByteBuf} and so do no memory copy whenever possible.
|
||||
* Be aware that {@link CompositeByteBuf} use a more complex indexing implementation so depending on your use-case
|
||||
* and the decoder implemention this may be slower then just use the {@link #MERGE_CUMULATOR}.
|
||||
* and the decoder implementation this may be slower then just use the {@link #MERGE_CUMULATOR}.
|
||||
*/
|
||||
public static final Cumulator COMPOSITE_CUMULATOR = new Cumulator() {
|
||||
@Override
|
||||
@ -196,7 +196,7 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
|
||||
public final void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
|
||||
ByteBuf buf = internalBuffer();
|
||||
int readable = buf.readableBytes();
|
||||
if (buf.isReadable()) {
|
||||
if (readable > 0) {
|
||||
ByteBuf bytes = buf.readBytes(readable);
|
||||
buf.release();
|
||||
ctx.fireChannelRead(bytes);
|
||||
|
Loading…
Reference in New Issue
Block a user