Optimize encoding of websocket frames by merge if possible
This commit is contained in:
parent
ee17139a03
commit
48b416f112
@ -186,8 +186,14 @@ public class WebSocket08FrameEncoder extends MessageToMessageEncoder<WebSocketFr
|
|||||||
}
|
}
|
||||||
out.add(buf);
|
out.add(buf);
|
||||||
} else {
|
} else {
|
||||||
out.add(buf);
|
if (buf.writableBytes() >= data.readableBytes()) {
|
||||||
out.add(data.retain());
|
// 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;
|
release = false;
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
Reference in New Issue
Block a user