From 33493ce2249c8a52cfb4fdd65fa4bcd2dbbfe91a Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 24 Apr 2024 08:54:20 -0400 Subject: [PATCH] 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; } }