The equals() method (and for that matter, also the compareTo() method) can become a performance hotspot (e.g. in a high-traffic HashMap). I was wondering what tricks folks have adopted to optimize these methods for these cases when they prove necessary.
IntelliJ IDEA, for example, generates the following:
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
...
}
What else have you come across that can be a guideline for writing a good performing equals()?