RFR: 8289389: Fix warnings: type should also implement hashCode() since it overrides Object.equals() [v2]
Kevin Rushforth
kcr at openjdk.org
Mon Jul 11 21:15:47 UTC 2022
On Mon, 11 Jul 2022 18:56:36 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:
>> @hjohn: yes, but at a price: Object.hash(Object ...) incurs overhead by creating a temporary Object[] + boxing of a Boolean.
>
> Ah, I didn't realize you checked how this is optimized by the JIT.
In order to reduce collisions, the hash of each component is typically added to `h * 31` even when that hash is 0, whereas you skip the `h = 31 * h` in the case of null. It might not be a problem in practice, since value and origin are unlikely to collide, being of different types, but you might want to look at it.
In any case, I need to time to look at it, which I won't have until after JavaFX 19 RDP1, so let's leave this until then.
-------------
PR: https://git.openjdk.org/jfx/pull/821
More information about the openjfx-dev
mailing list