Tiny optimizations

This commit is contained in:
Norman Maurer 2013-08-09 08:24:24 +02:00
parent e954eb1c20
commit 1547876e97
3 changed files with 12 additions and 10 deletions

View File

@ -165,14 +165,14 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
} catch (Throwable t) { } catch (Throwable t) {
throw new DecoderException(t); throw new DecoderException(t);
} finally { } finally {
if (out.isEmpty()) { int size = out.size();
if (size == 0) {
decodeWasNull = true; decodeWasNull = true;
} } else {
for (int i = 0; i < size; i ++) {
for (int i = 0; i < out.size(); i ++) {
ctx.fireChannelRead(out.get(i)); ctx.fireChannelRead(out.get(i));
} }
}
out.recycle(); out.recycle();
} }
} }
@ -207,8 +207,8 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
cumulation.release(); cumulation.release();
cumulation = null; cumulation = null;
} }
int size = out.size();
for (int i = 0; i < out.size(); i ++) { for (int i = 0; i < size; i ++) {
ctx.fireChannelRead(out.get(i)); ctx.fireChannelRead(out.get(i));
} }
ctx.fireChannelInactive(); ctx.fireChannelInactive();

View File

@ -98,7 +98,8 @@ public abstract class MessageToMessageDecoder<I> extends ChannelInboundHandlerAd
} catch (Exception e) { } catch (Exception e) {
throw new DecoderException(e); throw new DecoderException(e);
} finally { } finally {
for (int i = 0; i < out.size(); i ++) { int size = out.size();
for (int i = 0; i < size; i ++) {
ctx.fireChannelRead(out.get(i)); ctx.fireChannelRead(out.get(i));
} }
out.recycle(); out.recycle();

View File

@ -340,7 +340,8 @@ public abstract class ReplayingDecoder<S> extends ByteToMessageDecoder {
cumulation = null; cumulation = null;
} }
for (int i = 0; i < out.size(); i ++) { int size = out.size();
for (int i = 0; i < size; i ++) {
ctx.fireChannelRead(out.get(i)); ctx.fireChannelRead(out.get(i));
} }
ctx.fireChannelInactive(); ctx.fireChannelInactive();