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,16 +126,12 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
@Override
public boolean contains(Object o) {
if (o instanceof Channel) {
Channel c = (Channel) o;
if (o instanceof ServerChannel) {
return serverChannels.containsValue(c);
} else {
return nonServerChannels.containsValue(c);
}
} else {
return false;
if (o instanceof ServerChannel) {
return serverChannels.containsValue(o);
} else if (o instanceof Channel) {
return nonServerChannels.containsValue(o);
}
return false;
}
@Override