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
This commit is contained in:
Joe Darcy 2009-10-07 14:04:20 -07:00
parent 1c6255de3e
commit debdf79d18
7 changed files with 12 additions and 12 deletions

View File

@ -201,7 +201,7 @@ public final class Byte extends Number implements Comparable<Byte> {
*/ */
public static Byte valueOf(String s, int radix) public static Byte valueOf(String s, int radix)
throws NumberFormatException { throws NumberFormatException {
return new Byte(parseByte(s, radix)); return valueOf(parseByte(s, radix));
} }
/** /**
@ -277,7 +277,7 @@ public final class Byte extends Number implements Comparable<Byte> {
if (i < MIN_VALUE || i > MAX_VALUE) if (i < MIN_VALUE || i > MAX_VALUE)
throw new NumberFormatException( throw new NumberFormatException(
"Value " + i + " out of range from input " + nm); "Value " + i + " out of range from input " + nm);
return (byte)i; return valueOf((byte)i);
} }
/** /**
@ -374,7 +374,7 @@ public final class Byte extends Number implements Comparable<Byte> {
* base&nbsp;10. * base&nbsp;10.
*/ */
public String toString() { public String toString() {
return String.valueOf((int)value); return Integer.toString((int)value);
} }
/** /**

View File

@ -629,7 +629,7 @@ public final class Double extends Number implements Comparable<Double> {
* @see java.lang.Double#toString(double) * @see java.lang.Double#toString(double)
*/ */
public String toString() { public String toString() {
return String.valueOf(value); return toString(value);
} }
/** /**

View File

@ -551,7 +551,7 @@ public final class Float extends Number implements Comparable<Float> {
* @see java.lang.Float#toString(float) * @see java.lang.Float#toString(float)
*/ */
public String toString() { public String toString() {
return String.valueOf(value); return Float.toString(value);
} }
/** /**

View File

@ -746,7 +746,7 @@ public final class Integer extends Number implements Comparable<Integer> {
* base&nbsp;10. * base&nbsp;10.
*/ */
public String toString() { public String toString() {
return String.valueOf(value); return toString(value);
} }
/** /**

View File

@ -761,7 +761,7 @@ public final class Long extends Number implements Comparable<Long> {
* base&nbsp;10. * base&nbsp;10.
*/ */
public String toString() { public String toString() {
return String.valueOf(value); return toString(value);
} }
/** /**

View File

@ -170,7 +170,7 @@ public final class Short extends Number implements Comparable<Short> {
*/ */
public static Short valueOf(String s, int radix) public static Short valueOf(String s, int radix)
throws NumberFormatException { throws NumberFormatException {
return new Short(parseShort(s, radix)); return valueOf(parseShort(s, radix));
} }
/** /**
@ -282,7 +282,7 @@ public final class Short extends Number implements Comparable<Short> {
if (i < MIN_VALUE || i > MAX_VALUE) if (i < MIN_VALUE || i > MAX_VALUE)
throw new NumberFormatException( throw new NumberFormatException(
"Value " + i + " out of range from input " + nm); "Value " + i + " out of range from input " + nm);
return (short)i; return valueOf((short)i);
} }
/** /**
@ -379,7 +379,7 @@ public final class Short extends Number implements Comparable<Short> {
* base&nbsp;10. * base&nbsp;10.
*/ */
public String toString() { public String toString() {
return String.valueOf((int)value); return Integer.toString((int)value);
} }
/** /**

View File

@ -2995,7 +2995,7 @@ public final class String
* @see java.lang.Integer#toString(int, int) * @see java.lang.Integer#toString(int, int)
*/ */
public static String valueOf(int i) { public static String valueOf(int i) {
return Integer.toString(i, 10); return Integer.toString(i);
} }
/** /**
@ -3009,7 +3009,7 @@ public final class String
* @see java.lang.Long#toString(long) * @see java.lang.Long#toString(long)
*/ */
public static String valueOf(long l) { public static String valueOf(long l) {
return Long.toString(l, 10); return Long.toString(l);
} }
/** /**