classpath
[Top][All Lists]
Advanced

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

Re: Regression in Integer


From: Tom Tromey
Subject: Re: Regression in Integer
Date: 30 Jul 2001 11:32:25 -0600

>>>>> "Eric" == Eric Blake <address@hidden> writes:

Eric> I just noticed that your changes to Integer cause an infinite
Eric> loop in Classpath (but not in gcj).  You changed
Eric> Integer.toString(int) to call String.valueOf(int), since gcj
Eric> implements String.valueOf(int) natively.  But when
Eric> String.valueOf(int) is not native, it calls Integer.toString(i,
Eric> 10), which in turn calls Integer.toString(int) for the radix 10,
Eric> causing a 3-way infinite recursion.

Sorry about that.

I think that the optimization case in Integer.toString(int,int) is
overkill.  Anybody who calls toString(x,10), expecting full
performance, will just be disappointed.

So, instead of your patch, I'm just going to commit the appended.

If you, or anybody, thinks this is a bad idea, feel free to mention
it.  I'm open to changing it.

Tom

Index: ChangeLog
from  Tom Tromey  <address@hidden>
        * java/lang/Integer.java (toString(int,int)): Don't bother to
        optimize.

Index: java/lang/Integer.java
===================================================================
RCS file: /cvs/classpath/java/lang/Integer.java,v
retrieving revision 1.18
diff -u -r1.18 Integer.java
--- java/lang/Integer.java 2001/07/23 20:01:44 1.18
+++ java/lang/Integer.java 2001/07/30 17:02:02
@@ -267,11 +267,6 @@
    */
   public static String toString(int num, int radix)
   {
-    // Use optimized method for the typical case.
-    if (radix == 10 ||
-        radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
-      return toString(num);
-
     // For negative numbers, print out the absolute value w/ a leading '-'.
     // Use an array large enough for a binary number.
     char[] buffer = new char[33];



reply via email to

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