Optimize DefaultChannelId.equals
Motivation: A `DefaultChannelId` has final `hashCode` field calculated in the constructor. We can use it in `equals` to the fast return for different objects. Modifications: Use `hashCode` field in `DefaultChannelId.equals()`. Result: Fast `equals` on negative scenarios.
This commit is contained in:
parent
d2cb51bc2e
commit
e404690574
|
@ -274,7 +274,14 @@ public final class DefaultChannelId implements ChannelId {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return this == obj || (obj instanceof DefaultChannelId && Arrays.equals(data, ((DefaultChannelId) obj).data));
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof DefaultChannelId)) {
|
||||
return false;
|
||||
}
|
||||
DefaultChannelId other = (DefaultChannelId) obj;
|
||||
return hashCode == other.hashCode && Arrays.equals(data, other.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue
Block a user