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 GitHub
parent b1c57257af
commit 914b433a8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<SctpMessage> {
private final Map<Integer, ByteBuf> fragments = new HashMap<Integer, ByteBuf>();
private final IntObjectMap<ByteBuf> fragments = new IntObjectHashMap<ByteBuf>();
@Override
protected void decode(ChannelHandlerContext ctx, SctpMessage msg, List<Object> out) throws Exception {