Clean up `hashCode`/`equals` in `IntVersion`.
Avoid creating a boxed `Long`, and add the typical fast-path for reference equality.
@@ -48,17 +48,20 @@ final class IntVersion implements Version {
@Override
public int hashCode() {
- return Long.valueOf(val).hashCode();
+ return Long.hashCode(val);
}
@Override
public boolean equals(Object obj) {
- if (obj instanceof IntVersion) {
- IntVersion other = (IntVersion) obj;
- return other.val == val;
+ if (this == obj) {
+ return true;
}
+ if (!(obj instanceof IntVersion)) {
return false;
}
+ IntVersion other = (IntVersion) obj;
+ return other.val == val;
+ }
@Override
public String toString() {
