* Claes Redestad: > we're doing plenty of iterations over Set.of() instances during > bootstrap, which makes these operations show up prominently in > startup profiles. This patch refactors a few hot methods to get a > measureable startup improvement without regressing on targeted > microbenchmarks. > > Bug: https://bugs.openjdk.java.net/browse/JDK-8236641 > Webrev: http://cr.openjdk.java.net/~redestad/8236641/open.00/ > > (The patch is baselined against 8236850)
Would it be possible to replace idx = SALT % elements.length; idx = (SALT % (table.length >> 1)) << 1; with this? idx = (int) ((elements.length * (long) SALT) >>> 32); idx = (int) (((table.length >> 1) * (long) SALT) >>> 31); A long multiplication followed by a shift should be faster than an int modulo. See this thread for some background: <https://mail.openjdk.java.net/pipermail/hotspot-dev/2019-November/040011.html> Thanks, Florian