classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: String class: hack for ORP 1.0.9


From: Mark Wielaard
Subject: Re: String class: hack for ORP 1.0.9
Date: Tue, 12 Jul 2005 10:54:01 +0200

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 <address@hidden>
       * 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]