Add a method to calculate hash code from the provided int[], offset, length, and initial value.
Rationale: current utility methods for calculating hash code for int[] are insufficiently flexible. It's either ArraysSupport.vectorizedHashCode with an offset, length and initialValue, or Arrays.hashCode with just an array.
For an arbitrary int[], unconditional vectorization might not yield the best performance results, while also needlessly drawing reader's attention to the call site. That said, it's the only hashcode method that is capable of operating on an array subrange additionally taking the initial value.
While it might be premature to add a new method to Arrays, it can be added to ArraysSupport, to be used in JDK, for example, here:
* 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
Rationale: current utility methods for calculating hash code for int[] are insufficiently flexible. It's either ArraysSupport.vectorizedHashCode with an offset, length and initialValue, or Arrays.hashCode with just an array.
For an arbitrary int[], unconditional vectorization might not yield the best performance results, while also needlessly drawing reader's attention to the call site. That said, it's the only hashcode method that is capable of operating on an array subrange additionally taking the initial value.
While it might be premature to add a new method to Arrays, it can be added to ArraysSupport, to be used in JDK, for example, here:
* 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
- relates to
-
JDK-8331427 Rename confusingly named ArraysSupport.signedHashCode
- Resolved
-
JDK-8332826 Make hashCode methods in ArraysSupport friendlier
- Resolved
- links to
-
Review openjdk/jdk/14831