Get char once in loop while parsing.
This commit is contained in:
parent
2694d9ac3c
commit
33493ce224
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue