From 9e1e4f79c76f39c8d6efccbf8351e7d13ced8007 Mon Sep 17 00:00:00 2001 From: Sergey Polovko Date: Tue, 5 Jan 2016 00:40:35 +0300 Subject: [PATCH] Fix SctpMessage.duplicate() behavior Motivation: SctpMessage.duplicate() copied message content that leads to additional buffer allocation and memory copying. Modifications: Duplicate message content instead of copying it. Result: Better performace and less memory consumption. --- .../src/main/java/io/netty/channel/sctp/SctpMessage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transport-sctp/src/main/java/io/netty/channel/sctp/SctpMessage.java b/transport-sctp/src/main/java/io/netty/channel/sctp/SctpMessage.java index f809999d5d..d535fc9a27 100644 --- a/transport-sctp/src/main/java/io/netty/channel/sctp/SctpMessage.java +++ b/transport-sctp/src/main/java/io/netty/channel/sctp/SctpMessage.java @@ -160,7 +160,7 @@ public final class SctpMessage extends DefaultByteBufHolder { if (msgInfo == null) { return new SctpMessage(protocolIdentifier, streamIdentifier, unordered, content().duplicate()); } else { - return new SctpMessage(msgInfo, content().copy()); + return new SctpMessage(msgInfo, content().duplicate()); } }