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:
Nikolay Fedorovskikh 2017-09-08 00:39:32 +05:00 committed by Norman Maurer
parent d2cb51bc2e
commit e404690574

View File

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