In getBytes() you do not need:
int n = srcEnd;
int i = srcBegin;
You could already use srcEnd srcBegin


@@ -1015,16 +968,16 @@ public final class String
             return true;
         }
         if (anObject instanceof String) {
-            String anotherString = (String)anObject;
-                int n = count;
-                if (n == anotherString.count) {
+            String anotherString = (String) anObject;
+                int n = value.length;
+                if (n == anotherString.value.length) {
                     char v1[] = value;
                     char v2[] = anotherString.value;
-                    int i = offset;
-                    int j = anotherString.offset;
+                    int i = 0;
                     while (n-- != 0) {
-                        if (v1[i++] != v2[j++])
-                            return false;
+                        if (v1[i] != v2[i])
+                            return false;
+                        i++;
                     }
                     return true;
                 }

Why not simply? :
         if (anObject instanceof String) {
            String anotherString = (String) anObject;
                int n = value.length;
                if (n == anotherString.value.length) {
                     char v1[] = value;
                     char v2[] = anotherString.value;
                     while (n-- != 0) {
                        if (v1[n] != v2[n])
                            return false;
                     }
                     return true;
                 }
This additionally has the advantage, that mostly the difference would be found quicker, as strings of same length often would differ at the end e.g.:
VeryLongText_1
VeryLongText_2

Same for other equals and compare methods.

BTW: You again have inserted a space after casts. ;-)

-Ulf


Am 31.05.2012 05:22, schrieb mike.dui...@oracle.com:
Changeset: 2c773daa825d
Author:    mduigou
Date:      2012-05-17 10:06 -0700
URL:       http://hg.openjdk.java.net/jdk8/tl/jdk/rev/2c773daa825d

6924259: Remove offset and count fields from java.lang.String
Summary: Removes the use of shared character array buffers by String along with 
the two fields needed to support the use of shared buffers.
Reviewed-by: alanb, mduigou, forax, briangoetz
Contributed-by: brian.dohe...@oracle.com

! src/share/classes/java/lang/Integer.java
! src/share/classes/java/lang/Long.java
! src/share/classes/java/lang/String.java
! src/share/classes/java/lang/StringCoding.java


Reply via email to