RFR: 8306075: Micro-optimize Enum.hashCode [v2]
Claes Redestad
redestad at openjdk.org
Mon Apr 17 13:43:44 UTC 2023
On Mon, 17 Apr 2023 13:27:43 GMT, olivergillespie <duke at openjdk.org> wrote:
> > Why isn't `Enum::hashCode` simply doing `return ordinal;`?
>
> See https://bugs.openjdk.org/browse/JDK-8050217
Thanks! If there are apps where `Enum::hashCode` is performance sensitive then run-to-run stability may be a stronger argument than @stuart-marks et al argues it is here, though there might be some unspoken arguments about how it might affect iteration order et.c...
Adding a cached field to `Enum` seem innocuous though, whether it disappears into a padding gap or not.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13491#issuecomment-1511370298
More information about the core-libs-dev
mailing list