On Wed, 5 Jul 2023 17:44:52 GMT, Roger Riggs <rri...@openjdk.org> wrote:
>> You are right, I have no stats. Performance-wise, it's already better than >> what was there before. Before, there was no short-circuit check. But I can >> go either way; I don't have a strong opinion. >> >> Reusing superclass' equals is not often seen these days (and that code is >> old), so some amount of overlap is expected. Regardless of whether we >> rearrange that check or not, if the passed object is not `this`, we end up >> checking `this == obj` twice: once in super.equals, the other time in here. > > True, there's no simple way to avoid the double check in either the equal or > not equal case. > And I don't know enough about the Hotspot compiler to know whether it would > spot the duplication and optimize it. > In many `equals` methods, the test for self equality is frequently the first > line. > Is fine as is. Re-arranged the checks in f1ce3a1. You are right, this way is more conventional. As a bonus, we can dispense with the comment. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14752#discussion_r1254322430