changeset 1909:e7ad502130ba

6480728: Byte.valueOf(byte) returns a cached value but Byte.valueOf(String) 6655735: Integer.toString() and String.valueOf(int) contain slow delegations Reviewed-by: lancea
author darcy
date Wed, 07 Oct 2009 14:04:20 -0700
parents 777714bd992a
children 3b45b809d8ff b84f40617f90 405fd587f13f
files src/share/classes/java/lang/Byte.java src/share/classes/java/lang/Double.java src/share/classes/java/lang/Float.java src/share/classes/java/lang/Integer.java src/share/classes/java/lang/Long.java src/share/classes/java/lang/Short.java src/share/classes/java/lang/String.java
diffstat 7 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/lang/Byte.java	Wed Oct 07 13:53:11 2009 -0700
+++ b/src/share/classes/java/lang/Byte.java	Wed Oct 07 14:04:20 2009 -0700
@@ -201,7 +201,7 @@
      */
     public static Byte valueOf(String s, int radix)
         throws NumberFormatException {
-        return new Byte(parseByte(s, radix));
+        return valueOf(parseByte(s, radix));
     }
 
     /**
@@ -277,7 +277,7 @@
         if (i < MIN_VALUE || i > MAX_VALUE)
             throw new NumberFormatException(
                     "Value " + i + " out of range from input " + nm);
-        return (byte)i;
+        return valueOf((byte)i);
     }
 
     /**
@@ -374,7 +374,7 @@
      *          base&nbsp;10.
      */
     public String toString() {
-        return String.valueOf((int)value);
+        return Integer.toString((int)value);
     }
 
     /**
--- a/src/share/classes/java/lang/Double.java	Wed Oct 07 13:53:11 2009 -0700
+++ b/src/share/classes/java/lang/Double.java	Wed Oct 07 14:04:20 2009 -0700
@@ -629,7 +629,7 @@
      * @see java.lang.Double#toString(double)
      */
     public String toString() {
-        return String.valueOf(value);
+        return toString(value);
     }
 
     /**
--- a/src/share/classes/java/lang/Float.java	Wed Oct 07 13:53:11 2009 -0700
+++ b/src/share/classes/java/lang/Float.java	Wed Oct 07 14:04:20 2009 -0700
@@ -551,7 +551,7 @@
      * @see java.lang.Float#toString(float)
      */
     public String toString() {
-        return String.valueOf(value);
+        return Float.toString(value);
     }
 
     /**
--- a/src/share/classes/java/lang/Integer.java	Wed Oct 07 13:53:11 2009 -0700
+++ b/src/share/classes/java/lang/Integer.java	Wed Oct 07 14:04:20 2009 -0700
@@ -746,7 +746,7 @@
      *          base&nbsp;10.
      */
     public String toString() {
-        return String.valueOf(value);
+        return toString(value);
     }
 
     /**
--- a/src/share/classes/java/lang/Long.java	Wed Oct 07 13:53:11 2009 -0700
+++ b/src/share/classes/java/lang/Long.java	Wed Oct 07 14:04:20 2009 -0700
@@ -761,7 +761,7 @@
      *          base&nbsp;10.
      */
     public String toString() {
-        return String.valueOf(value);
+        return toString(value);
     }
 
     /**
--- a/src/share/classes/java/lang/Short.java	Wed Oct 07 13:53:11 2009 -0700
+++ b/src/share/classes/java/lang/Short.java	Wed Oct 07 14:04:20 2009 -0700
@@ -170,7 +170,7 @@
      */
     public static Short valueOf(String s, int radix)
         throws NumberFormatException {
-        return new Short(parseShort(s, radix));
+        return valueOf(parseShort(s, radix));
     }
 
     /**
@@ -282,7 +282,7 @@
         if (i < MIN_VALUE || i > MAX_VALUE)
             throw new NumberFormatException(
                     "Value " + i + " out of range from input " + nm);
-        return (short)i;
+        return valueOf((short)i);
     }
 
     /**
@@ -379,7 +379,7 @@
      *          base&nbsp;10.
      */
     public String toString() {
-        return String.valueOf((int)value);
+        return Integer.toString((int)value);
     }
 
     /**
--- a/src/share/classes/java/lang/String.java	Wed Oct 07 13:53:11 2009 -0700
+++ b/src/share/classes/java/lang/String.java	Wed Oct 07 14:04:20 2009 -0700
@@ -2995,7 +2995,7 @@
      * @see     java.lang.Integer#toString(int, int)
      */
     public static String valueOf(int i) {
-        return Integer.toString(i, 10);
+        return Integer.toString(i);
     }
 
     /**
@@ -3009,7 +3009,7 @@
      * @see     java.lang.Long#toString(long)
      */
     public static String valueOf(long l) {
-        return Long.toString(l, 10);
+        return Long.toString(l);
     }
 
     /**