javaprims.h (_Jv_FormatInt): New declaration.
* gcj/javaprims.h (_Jv_FormatInt): New declaration. * java/lang/natString.cc (_JvFormatInt): New primitive, with logic taken from old Integer.toString code. (Integer::valueOf): Use _Jv_FormatInt. * java/lang/Integer.java (toString): Just use call String.valueOf. * java/lang/Long.java (toString): Fix typo in comment. * java/lang/String.java (valueOf(int)): Make native. * java/lang/StringBuffer.java (append(int)): Make native. * java/lang/natStringBuffer.cc: New file, for append(jint). * Makefile.am (ant_source_files): Add java/lang/natStringBuffer.cc. From-SVN: r42419
This commit is contained in:
parent
f5d6a24c2e
commit
ef0a7b49a9
10 changed files with 98 additions and 40 deletions
|
@ -267,35 +267,7 @@ public final class Integer extends Number implements Comparable
|
|||
|
||||
public static String toString(int num)
|
||||
{
|
||||
// Use an arrary large enough for "-2147483648"; i.e. 11 chars.
|
||||
char[] buffer = new char[11];
|
||||
int i = 11;
|
||||
boolean isNeg;
|
||||
if (num < 0)
|
||||
{
|
||||
isNeg = true;
|
||||
num = -(num);
|
||||
if (num < 0)
|
||||
{
|
||||
// Must be MIN_VALUE, so handle this special case.
|
||||
buffer[--i] = '8';
|
||||
num = 214748364;
|
||||
}
|
||||
}
|
||||
else
|
||||
isNeg = false;
|
||||
|
||||
do
|
||||
{
|
||||
buffer[--i] = (char) ((int) '0' + (num % 10));
|
||||
num /= 10;
|
||||
}
|
||||
while (num > 0);
|
||||
|
||||
if (isNeg)
|
||||
buffer[--i] = '-';
|
||||
|
||||
return String.valueOf(buffer, i, 11-i);
|
||||
return String.valueOf (num);
|
||||
}
|
||||
|
||||
public static String toString(int num, int radix)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue