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

(str) Improve String.hashCode implementation

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      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

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

                  Dates

                  Created:
                  Updated:
                  Resolved: