Simplify ByteToMessageDecoder#callDecode (#11224)
Motivation: After the if case, outSize is always 0, so we can simplify the code. Modification: Simplify code by not updating and using `isEmpty()`. Result: Clearer than before
This commit is contained in:
parent
bb7b05be01
commit
b8a5148569
@ -426,7 +426,7 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
|
|||||||
protected void callDecode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
|
protected void callDecode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
|
||||||
try {
|
try {
|
||||||
while (in.isReadable()) {
|
while (in.isReadable()) {
|
||||||
int outSize = out.size();
|
final int outSize = out.size();
|
||||||
|
|
||||||
if (outSize > 0) {
|
if (outSize > 0) {
|
||||||
fireChannelRead(ctx, out, outSize);
|
fireChannelRead(ctx, out, outSize);
|
||||||
@ -440,7 +440,6 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
|
|||||||
if (ctx.isRemoved()) {
|
if (ctx.isRemoved()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
outSize = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int oldInputLength = in.readableBytes();
|
int oldInputLength = in.readableBytes();
|
||||||
@ -454,7 +453,7 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outSize == out.size()) {
|
if (out.isEmpty()) {
|
||||||
if (oldInputLength == in.readableBytes()) {
|
if (oldInputLength == in.readableBytes()) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user