8267844: Replace Integer/Long.valueOf() with Integer/Long.parse*() where applicable

Reviewed-by: redestad
This commit is contained in:
Sergey Tsypanov 2021-08-12 10:03:52 +00:00 committed by Claes Redestad
parent d38b31438d
commit b29fbad940
6 changed files with 31 additions and 13 deletions

View file

@ -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;
}