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

(str) Improve String.hashCode implementation

XMLWordPrintable

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

        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.

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

                Created:
                Updated:
                Resolved: