Correctly calculate the initial size of the LinkedHashMap during DefaultChannelGroup.write* (#10055)

Motivation:

We should not include the number of ServerChannel that are part of the DefaultChannelGroup when specify the initial size of the LinkedHashMap

Modifications:

Only use the number of the non ServerChannel

Result:

Reduce memory-footprint
This commit is contained in:
Norman Maurer 2020-02-24 19:29:08 +01:00
parent e33c5f3a89
commit 7542f1f13c

View File

@ -263,7 +263,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
}
future = voidFuture;
} else {
Map<Channel, ChannelFuture> futures = new LinkedHashMap<>(size());
Map<Channel, ChannelFuture> futures = new LinkedHashMap<>(nonServerChannels.size());
for (Channel c: nonServerChannels.values()) {
if (matcher.matches(c)) {
futures.put(c, c.write(safeDuplicate(message)));
@ -396,7 +396,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
}
future = voidFuture;
} else {
Map<Channel, ChannelFuture> futures = new LinkedHashMap<>(size());
Map<Channel, ChannelFuture> futures = new LinkedHashMap<>(nonServerChannels.size());
for (Channel c: nonServerChannels.values()) {
if (matcher.matches(c)) {
futures.put(c, c.writeAndFlush(safeDuplicate(message)));