Skip to content

Commit

Permalink
Simplify DefaultChannelGroup.contains(...) and so remove one instance…
Browse files Browse the repository at this point in the history
…of check.

Motivation:

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

Modifications:

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

Result:

Simplier and cheaper implementation.
  • Loading branch information
normanmaurer committed Mar 17, 2018
1 parent de082bf commit 0adccfd
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,12 @@ public int size() {

@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
Expand Down

0 comments on commit 0adccfd

Please sign in to comment.