From 914b433a8dad50132f34df2b2da501c31e218790 Mon Sep 17 00:00:00 2001 From: feijermu Date: Tue, 25 Feb 2020 02:57:55 +0800 Subject: [PATCH] Replace the type of fragments field with IntObjectMap in SctpMessageCompletionHandler (#10057) Motivation: The type IntObjectMap with the key of primitive int can help lower the cost of boxing and unboxing, and improve performance. I think it's more suitable for fragments field in SctpMessageCompletionHandler.java. Modification: Just replace the type of fragments field with IntObjectMap. Result: Improve performance slightly while decoding sctp message. --- .../handler/codec/sctp/SctpMessageCompletionHandler.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/transport-sctp/src/main/java/io/netty/handler/codec/sctp/SctpMessageCompletionHandler.java b/transport-sctp/src/main/java/io/netty/handler/codec/sctp/SctpMessageCompletionHandler.java index 0a09a5e847..7f6de637eb 100644 --- a/transport-sctp/src/main/java/io/netty/handler/codec/sctp/SctpMessageCompletionHandler.java +++ b/transport-sctp/src/main/java/io/netty/handler/codec/sctp/SctpMessageCompletionHandler.java @@ -22,10 +22,10 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandler; import io.netty.channel.sctp.SctpMessage; import io.netty.handler.codec.MessageToMessageDecoder; +import io.netty.util.collection.IntObjectHashMap; +import io.netty.util.collection.IntObjectMap; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * {@link MessageToMessageDecoder} which will take care of handle fragmented {@link SctpMessage}s, so @@ -33,7 +33,7 @@ import java.util.Map; * {@link ChannelInboundHandler}. */ public class SctpMessageCompletionHandler extends MessageToMessageDecoder { - private final Map fragments = new HashMap(); + private final IntObjectMap fragments = new IntObjectHashMap(); @Override protected void decode(ChannelHandlerContext ctx, SctpMessage msg, List out) throws Exception {