From dc6e2cd62537ce1b60ccf9e7ad09efb04f155d40 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Thu, 20 Jun 2013 15:51:56 +0900 Subject: [PATCH] Make AbstractMemoryHttpData generate less garbage --- .../codec/http/multipart/AbstractMemoryHttpData.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractMemoryHttpData.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractMemoryHttpData.java index bca48b7700..ac83db6ad9 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractMemoryHttpData.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractMemoryHttpData.java @@ -16,6 +16,7 @@ package io.netty.handler.codec.http.multipart; import io.netty.buffer.ByteBuf; +import io.netty.buffer.CompositeByteBuf; import io.netty.handler.codec.http.HttpConstants; import java.io.File; @@ -91,8 +92,15 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData { size += localsize; if (byteBuf == null) { byteBuf = buffer; + } else if (byteBuf instanceof CompositeByteBuf) { + CompositeByteBuf cbb = (CompositeByteBuf) byteBuf; + cbb.addComponent(buffer); + cbb.writerIndex(cbb.writerIndex() + buffer.readableBytes()); } else { - byteBuf = wrappedBuffer(byteBuf, buffer); + CompositeByteBuf cbb = compositeBuffer(); + cbb.addComponent(buffer); + cbb.writerIndex(buffer.readableBytes()); + byteBuf = cbb; } } if (last) {