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:
chenqwwq 2021-05-07 17:37:30 +08:00 committed by GitHub
parent bb7b05be01
commit b8a5148569
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -426,7 +426,7 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
protected void callDecode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
try {
while (in.isReadable()) {
int outSize = out.size();
final int outSize = out.size();
if (outSize > 0) {
fireChannelRead(ctx, out, outSize);
@ -440,7 +440,6 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
if (ctx.isRemoved()) {
break;
}
outSize = 0;
}
int oldInputLength = in.readableBytes();
@ -454,7 +453,7 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
break;
}
if (outSize == out.size()) {
if (out.isEmpty()) {
if (oldInputLength == in.readableBytes()) {
break;
} else {