6921374: java.lang.String::hashCode() should check for count == 0 to avoid repeated stores hash = 0
authoralanb
Sat, 27 Feb 2010 19:29:15 +0000
changeset 4982 8e7376ac6830
parent 4981 3a3f498acc86
child 4984 48c6904d5e14
6921374: java.lang.String::hashCode() should check for count == 0 to avoid repeated stores hash = 0 Reviewed-by: darcy, ohair
jdk/src/share/classes/java/lang/String.java
--- a/jdk/src/share/classes/java/lang/String.java	Sat Feb 27 19:26:59 2010 +0000
+++ b/jdk/src/share/classes/java/lang/String.java	Sat Feb 27 19:29:15 2010 +0000
@@ -1492,7 +1492,7 @@
      */
     public int hashCode() {
         int h = hash;
-        if (h == 0) {
+        if (h == 0 && count > 0) {
             int off = offset;
             char val[] = value;
             int len = count;