Skip to content

Commit

Permalink
Replace the type of fragments field with IntObjectMap in SctpMessageC…
Browse files Browse the repository at this point in the history
…ompletionHandler (#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.
  • Loading branch information
seedeed committed Feb 24, 2020
1 parent b1c5725 commit 914b433
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@
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
* only <strong>complete</strong> {@link SctpMessage}s will be forwarded to the next
* {@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 {
Expand Down

0 comments on commit 914b433

Please sign in to comment.