From e96531839822be2966bbdd34181cf9397a7bd829 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Fri, 13 Dec 2013 11:39:39 +0100 Subject: [PATCH] Optimize encoding of websocket frames by merge if possible --- .../codec/http/websocketx/WebSocket08FrameEncoder.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameEncoder.java index 19ee9d0787..bdad55b928 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameEncoder.java @@ -186,8 +186,14 @@ public class WebSocket08FrameEncoder extends MessageToMessageEncoder= data.readableBytes()) { + // merge buffers as this is cheaper then a gathering write if the payload is small enough + buf.writeBytes(data); + out.add(buf); + } else { + out.add(buf); + out.add(data.retain()); + } } release = false; } finally {