Tiny optimization

This commit is contained in:
Norman Maurer 2013-07-11 15:47:29 +02:00
parent e85ae721b2
commit 64686deaff

View File

@ -802,9 +802,10 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws SSLException {
int packetLength = this.packetLength;
final int readableBytes = in.readableBytes();
if (packetLength == 0) {
// the previous packet was consumed so try to read the length of the next packet
final int readableBytes = in.readableBytes();
if (readableBytes < 5) {
// not enough bytes readable to read the packet length
return;
@ -825,7 +826,7 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH
this.packetLength = packetLength;
}
if (in.readableBytes() < packetLength) {
if (readableBytes < packetLength) {
// wait until the whole packet can be read
return;
}