(str) Improve String.hashCode implementation

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P4
    • 9
    • Affects Version/s: None
    • Component/s: 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.

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

                Created:
                Updated:
                Resolved: