mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +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
|
@ -1254,7 +1254,7 @@ public final class Long extends Number
|
|||
int radix = 10;
|
||||
int index = 0;
|
||||
boolean negative = false;
|
||||
Long result;
|
||||
long result;
|
||||
|
||||
if (nm.isEmpty())
|
||||
throw new NumberFormatException("Zero length string");
|
||||
|
@ -1284,15 +1284,15 @@ public final class Long extends Number
|
|||
throw new NumberFormatException("Sign character in wrong position");
|
||||
|
||||
try {
|
||||
result = Long.valueOf(nm.substring(index), radix);
|
||||
result = negative ? Long.valueOf(-result.longValue()) : result;
|
||||
result = parseLong(nm, index, nm.length(), radix);
|
||||
result = negative ? -result : result;
|
||||
} catch (NumberFormatException e) {
|
||||
// If number is Long.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 = Long.valueOf(constant, radix);
|
||||
result = parseLong(constant, radix);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue