On Tue, 2005-07-12 at 13:02 +1200, Simon Kitching wrote:
> I just wondered if it was time to remove this hack...

Wow, that is a very old workaround. And indeed a nice optimization to
have. A quick startup of eclipse (with just a little project) shows 4642
hits of String.toCharArray() of which 4200 have (count == value.length).
Thanks for finding this.

Committed as:

       Reported by Simon Kitching <[EMAIL PROTECTED]>
       * java/lang/String.java (toCharArray): Return value.clone() when
       count == value.length.

Cheers,

Mark

diff -u -r1.67 String.java
--- java/lang/String.java       11 Jul 2005 22:30:07 -0000      1.67
+++ java/lang/String.java       12 Jul 2005 08:48:23 -0000
@@ -1499,10 +1499,9 @@
    */
   public char[] toCharArray()
   {
-    // XXX ORP 1.0.9 crashes on (char[]) clone() during bootstrap, so we
-    // omit this optimization for now.
-    // if (count == value.length)
-    //   return (char[]) value.clone();
+    if (count == value.length)
+      return (char[]) value.clone();
+
     char[] copy = new char[count];
     VMSystem.arraycopy(value, offset, copy, 0, count);
     return copy;

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath

Reply via email to