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

(str) Improve String.hashCode implementation

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P4
    • 9
    • None
    • core-libs
    • None
    • b33

    Backports

      Description

        We might want to clean up the String.hashCode() implementation.

        Let the patch speak for itself:
         http://cr.openjdk.java.net/~shade/8058643/webrev.01/

        It improves the readability, and also does not affect performance much:
         http://cr.openjdk.java.net/~shade/8058643/StringHashCode.java

        The improvement in nonCached case seems to be due to slightly better code generation, if one can closely examine the assembly:
         http://cr.openjdk.java.net/~shade/8058643/baseline.perfasm
         http://cr.openjdk.java.net/~shade/8058643/patched.perfasm

        It seems to be because we have one less branch checking for value.length.

        Attachments

          Issue Links

            Activity

              People

                shade Aleksey Shipilev
                shade Aleksey Shipilev
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: