diff options
author | PJ Fanning <fanningpj@apache.org> | 2021-01-18 14:20:02 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2021-01-18 14:20:02 +0000 |
commit | 06ea5add363cb246a566edd3abba238d5da0051e (patch) | |
tree | 768ebe66b0727c0da6c376abac7a5698b9550b79 /src | |
parent | 8f2c722fd3818abeaef2aeb72a8e58b29a8dca08 (diff) | |
download | poi-06ea5add363cb246a566edd3abba238d5da0051e.tar.gz poi-06ea5add363cb246a566edd3abba238d5da0051e.zip |
[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
Diffstat (limited to 'src')
-rw-r--r-- | src/java/org/apache/poi/ss/formula/eval/OperandResolver.java | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/java/org/apache/poi/ss/formula/eval/OperandResolver.java b/src/java/org/apache/poi/ss/formula/eval/OperandResolver.java index 162410f159..59a383c3e1 100644 --- a/src/java/org/apache/poi/ss/formula/eval/OperandResolver.java +++ b/src/java/org/apache/poi/ss/formula/eval/OperandResolver.java @@ -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) { |