You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/04/24 12:58:39 UTC
(commons-lang) 01/02: Get char once in loop while parsing.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit 33493ce2249c8a52cfb4fdd65fa4bcd2dbbfe91a
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Apr 24 08:54:20 2024 -0400
Get char once in loop while parsing.
---
src/main/java/org/apache/commons/lang3/math/NumberUtils.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
index c0b47929d..cc2eebc80 100644
--- a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
+++ b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
@@ -1832,14 +1832,15 @@ public class NumberUtils {
private static boolean withDecimalsParsing(final String str, final int beginIdx) {
int decimalPoints = 0;
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) {
decimalPoints++;
}
if (decimalPoints > 1) {
return false;
}
- if (!isDecimalPoint && !Character.isDigit(str.charAt(i))) {
+ if (!isDecimalPoint && !Character.isDigit(ch)) {
return false;
}
}