From 7fb64e2046543895cbec1d3b67ddfb2b1f6517a3 Mon Sep 17 00:00:00 2001 From: norman Date: Thu, 24 May 2012 08:47:35 +0200 Subject: [PATCH] A small optimization for the fix of #360 --- .../java/io/netty/buffer/ChannelBufferInputStream.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/buffer/src/main/java/io/netty/buffer/ChannelBufferInputStream.java b/buffer/src/main/java/io/netty/buffer/ChannelBufferInputStream.java index 0fd6d52d97..0d5d4f163c 100644 --- a/buffer/src/main/java/io/netty/buffer/ChannelBufferInputStream.java +++ b/buffer/src/main/java/io/netty/buffer/ChannelBufferInputStream.java @@ -195,9 +195,10 @@ public class ChannelBufferInputStream extends InputStream implements DataInput { lineBuf.append((char) b); } - while ( lineBuf.length() > 0 && - lineBuf.charAt(lineBuf.length() - 1) == '\r') { - lineBuf.setLength(lineBuf.length() - 1); + if (lineBuf.length() > 0 ) { + while (lineBuf.charAt(lineBuf.length() - 1) == '\r') { + lineBuf.setLength(lineBuf.length() - 1); + } } return lineBuf.toString();