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.
This commit is contained in:
feijermu 2020-02-25 02:57:55 +08:00 committed by Norman Maurer
parent 7542f1f13c
commit 9be003eb19
1 changed files with 3 additions and 4 deletions

View File

@ -22,9 +22,8 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelHandler;
import io.netty.channel.sctp.SctpMessage;
import io.netty.handler.codec.MessageToMessageDecoder;
import java.util.HashMap;
import java.util.Map;
import io.netty.util.collection.IntObjectHashMap;
import io.netty.util.collection.IntObjectMap;
/**
* {@link MessageToMessageDecoder} which will take care of handle fragmented {@link SctpMessage}s, so
@ -32,7 +31,7 @@ import java.util.Map;
* {@link ChannelHandler}.
*/
public class SctpMessageCompletionHandler extends MessageToMessageDecoder<SctpMessage> {
private final Map<Integer, ByteBuf> fragments = new HashMap<>();
private final IntObjectMap<ByteBuf> fragments = new IntObjectHashMap<ByteBuf>();
@Override
protected void decode(ChannelHandlerContext ctx, SctpMessage msg) throws Exception {