Improve SctpMessageCompletionHandler
Motivation: Avoid multiple search in fragments map Modifications: Replace usage of Map.containsKey by Map.remove Result: During packet process, fragment is only search once in the map instead of 3 times in the previous worst case
This commit is contained in:
parent
4a5340eae7
commit
8d6f0a3ce4
@ -43,10 +43,8 @@ public class SctpMessageCompletionHandler extends MessageToMessageDecoder<SctpMe
|
||||
final boolean isComplete = msg.isComplete();
|
||||
final boolean isUnordered = msg.isUnordered();
|
||||
|
||||
ByteBuf frag;
|
||||
if (fragments.containsKey(streamIdentifier)) {
|
||||
frag = fragments.remove(streamIdentifier);
|
||||
} else {
|
||||
ByteBuf frag = fragments.remove(streamIdentifier);
|
||||
if (frag == null) {
|
||||
frag = Unpooled.EMPTY_BUFFER;
|
||||
}
|
||||
|
||||
@ -58,7 +56,6 @@ public class SctpMessageCompletionHandler extends MessageToMessageDecoder<SctpMe
|
||||
fragments.put(streamIdentifier, Unpooled.wrappedBuffer(frag, byteBuf));
|
||||
} else if (isComplete && frag.isReadable()) {
|
||||
//last message to complete
|
||||
fragments.remove(streamIdentifier);
|
||||
SctpMessage assembledMsg = new SctpMessage(
|
||||
protocolIdentifier,
|
||||
streamIdentifier,
|
||||
|
Loading…
Reference in New Issue
Block a user