[github-215] Improve Performance of OperandResolver#parseDouble. Thanks to Robert Wenzel. This closes #215

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1885651 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2021-01-18 14:20:02 +00:00
parent 8f2c722fd3
commit 06ea5add36
1 changed files with 4 additions and 4 deletions

View File

@ -41,8 +41,8 @@ public final class OperandResolver {
"[+-]?(" +
"("+Digits+"(\\.)?("+Digits+"?)("+Exp+")?)|"+
"(\\."+Digits+"("+Exp+")?))"+
"[\\x00-\\x20]*");
"[\\x00-\\x20]*");
private static final Pattern fpPattern = Pattern.compile(fpRegex);
private OperandResolver() {
// no instances of this class
@ -291,8 +291,8 @@ public final class OperandResolver {
* @return <code>null</code> if the specified text cannot be parsed as a number
*/
public static Double parseDouble(String pText) {
if (Pattern.matches(fpRegex, pText))
if (fpPattern.matcher(pText).matches())
try {
return Double.parseDouble(pText);
} catch (NumberFormatException e) {