mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8267844: Replace Integer/Long.valueOf() with Integer/Long.parse*() where applicable
Reviewed-by: redestad
This commit is contained in:
parent
d38b31438d
commit
b29fbad940
6 changed files with 31 additions and 13 deletions
|
@ -1413,7 +1413,7 @@ public final class Integer extends Number
|
|||
int radix = 10;
|
||||
int index = 0;
|
||||
boolean negative = false;
|
||||
Integer result;
|
||||
int result;
|
||||
|
||||
if (nm.isEmpty())
|
||||
throw new NumberFormatException("Zero length string");
|
||||
|
@ -1443,15 +1443,15 @@ public final class Integer extends Number
|
|||
throw new NumberFormatException("Sign character in wrong position");
|
||||
|
||||
try {
|
||||
result = Integer.valueOf(nm.substring(index), radix);
|
||||
result = negative ? Integer.valueOf(-result.intValue()) : result;
|
||||
result = parseInt(nm, index, nm.length(), radix);
|
||||
result = negative ? -result : result;
|
||||
} catch (NumberFormatException e) {
|
||||
// If number is Integer.MIN_VALUE, we'll end up here. The next line
|
||||
// handles this case, and causes any genuine format error to be
|
||||
// rethrown.
|
||||
String constant = negative ? ("-" + nm.substring(index))
|
||||
: nm.substring(index);
|
||||
result = Integer.valueOf(constant, radix);
|
||||
result = parseInt(constant, radix);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue