Simplify DefaultChannelGroup.contains(...) and so remove one instanceof check.

Motivation:

DefaultChannelGroup.contains(...) did one more instanceof check then needed.

Modifications:

Simplify contains(...) and remove one instanceof check.

Result:

Simplier and cheaper implementation.
This commit is contained in:
Norman Maurer 2018-03-16 21:48:54 +01:00 committed by Norman Maurer
parent de082bf4c7
commit 0adccfdb50

View File

@ -126,17 +126,13 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
@Override @Override
public boolean contains(Object o) { public boolean contains(Object o) {
if (o instanceof Channel) {
Channel c = (Channel) o;
if (o instanceof ServerChannel) { if (o instanceof ServerChannel) {
return serverChannels.containsValue(c); return serverChannels.containsValue(o);
} else { } else if (o instanceof Channel) {
return nonServerChannels.containsValue(c); return nonServerChannels.containsValue(o);
} }
} else {
return false; return false;
} }
}
@Override @Override
public boolean add(Channel channel) { public boolean add(Channel channel) {