From 18ef05d70d3b5ac90e8df8b80cd83af82b82197b Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Sat, 1 Feb 2014 20:09:25 +0100 Subject: [PATCH] Use the pooled allocator for performance reasons --- .../java/com/squareup/okhttp/benchmarks/NettyHttpClient.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/benchmarks/src/main/java/com/squareup/okhttp/benchmarks/NettyHttpClient.java b/benchmarks/src/main/java/com/squareup/okhttp/benchmarks/NettyHttpClient.java index d5adec5a053b..cf3912384850 100644 --- a/benchmarks/src/main/java/com/squareup/okhttp/benchmarks/NettyHttpClient.java +++ b/benchmarks/src/main/java/com/squareup/okhttp/benchmarks/NettyHttpClient.java @@ -19,9 +19,11 @@ import com.squareup.okhttp.internal.Util; import io.netty.bootstrap.Bootstrap; import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelOption; import io.netty.channel.ChannelPipeline; import io.netty.channel.EventLoopGroup; import io.netty.channel.SimpleChannelInboundHandler; @@ -81,6 +83,7 @@ public class NettyHttpClient implements HttpClient { EventLoopGroup group = new NioEventLoopGroup(); bootstrap = new Bootstrap(); bootstrap.group(group) + .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .channel(NioSocketChannel.class) .handler(channelInitializer); }