Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8311864

Add ArraysSupport.hashCode(int[] a, fromIndex, length, initialValue)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Other
    • P4
    • 23
    • 22
    • core-libs
    • None

    Description

      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

      Attachments

        Issue Links

          Activity

            People

              prappo Pavel Rappo
              prappo Pavel Rappo
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: