Get char once in loop while parsing.

This commit is contained in:
Gary Gregory 2024-04-24 08:54:20 -04:00
parent 2694d9ac3c
commit 33493ce224
1 changed files with 3 additions and 2 deletions

View File

@ -1832,14 +1832,15 @@ public class NumberUtils {
private static boolean withDecimalsParsing(final String str, final int beginIdx) { private static boolean withDecimalsParsing(final String str, final int beginIdx) {
int decimalPoints = 0; int decimalPoints = 0;
for (int i = beginIdx; i < str.length(); i++) { for (int i = beginIdx; i < str.length(); i++) {
final boolean isDecimalPoint = str.charAt(i) == '.'; final char ch = str.charAt(i);
final boolean isDecimalPoint = ch == '.';
if (isDecimalPoint) { if (isDecimalPoint) {
decimalPoints++; decimalPoints++;
} }
if (decimalPoints > 1) { if (decimalPoints > 1) {
return false; return false;
} }
if (!isDecimalPoint && !Character.isDigit(str.charAt(i))) { if (!isDecimalPoint && !Character.isDigit(ch)) {
return false; return false;
} }
} }