On Wed, 5 Jul 2023 12:57:19 GMT, Pavel Rappo <pra...@openjdk.org> wrote:
> Unfortunately, we don't have mid-layer methods in between Arrays.hashCode and > ArraysSupport.vectorizedHashCode like that of Arrays.mismatch and > ArraysSupport.vectorizedMismatch. It's either all the null check but > short-circuits or unconditional vectorization but the initial value. I wonder > if we could consider `ArraysSupport.hashCode($type[] array, int fromIndex, > int length, int initialValue)` overloads, which could be useful beyond > BigInteger, as I've already seen in JDK. Contributors to ArraysSupport, > @PaulSandoz, @ChrisHegarty, @cl4es, @stuart-marks; thoughts? Here are a few more examples of code that could benefit from such a mid-layer API: * https://github.com/openjdk/jdk/blob/0ef03f122866f010ebf50683097e9b92e41cdaad/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java#L1076-L1083 * https://github.com/openjdk/jdk/blob/0ef03f122866f010ebf50683097e9b92e41cdaad/src/java.base/share/classes/java/util/ArrayList.java#L669-L680 * https://github.com/openjdk/jdk/blob/0ef03f122866f010ebf50683097e9b92e41cdaad/src/java.base/share/classes/sun/security/pkcs10/PKCS10.java#L356-L362 While we are here, shouldn't this be called `unsignedHashCode` rather than `signedHashCode`? https://github.com/openjdk/jdk/blob/0ef03f122866f010ebf50683097e9b92e41cdaad/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java#L214-L220 ------------- PR Comment: https://git.openjdk.org/jdk/pull/14630#issuecomment-1625253882