Eliminate unnessary copy of ByteBuf on ByteToMessageDecoder removal (#9662)
Motivation: At the moment we do a ByteBuf.readBytes(...) on removal of the ByteToMessageDecoder if there are any bytes left and forward the returned ByteBuf to the next handler in the pipeline. This is not really needed as we can just forward the cumulation buffer directly and so eliminate the extra memory copy Modifications: Just forward the cumulation buffer directly on removal of the ByteToMessageDecoder Result: Less memory copies
This commit is contained in:
parent
a84bd61631
commit
c462ec960b
@ -245,9 +245,7 @@ public abstract class ByteToMessageDecoder extends ChannelHandlerAdapter impleme
|
|||||||
numReads = 0;
|
numReads = 0;
|
||||||
int readable = buf.readableBytes();
|
int readable = buf.readableBytes();
|
||||||
if (readable > 0) {
|
if (readable > 0) {
|
||||||
ByteBuf bytes = buf.readBytes(readable);
|
ctx.fireChannelRead(buf);
|
||||||
buf.release();
|
|
||||||
ctx.fireChannelRead(bytes);
|
|
||||||
ctx.fireChannelReadComplete();
|
ctx.fireChannelReadComplete();
|
||||||
} else {
|
} else {
|
||||||
buf.release();
|
buf.release();
|
||||||
|
Loading…
Reference in New Issue
Block a user