mirror of https://github.com/apache/poi.git
[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:
parent
8f2c722fd3
commit
06ea5add36
|
@ -41,8 +41,8 @@ public final class OperandResolver {
|
||||||
"[+-]?(" +
|
"[+-]?(" +
|
||||||
"("+Digits+"(\\.)?("+Digits+"?)("+Exp+")?)|"+
|
"("+Digits+"(\\.)?("+Digits+"?)("+Exp+")?)|"+
|
||||||
"(\\."+Digits+"("+Exp+")?))"+
|
"(\\."+Digits+"("+Exp+")?))"+
|
||||||
"[\\x00-\\x20]*");
|
"[\\x00-\\x20]*");
|
||||||
|
private static final Pattern fpPattern = Pattern.compile(fpRegex);
|
||||||
|
|
||||||
private OperandResolver() {
|
private OperandResolver() {
|
||||||
// no instances of this class
|
// 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
|
* @return <code>null</code> if the specified text cannot be parsed as a number
|
||||||
*/
|
*/
|
||||||
public static Double parseDouble(String pText) {
|
public static Double parseDouble(String pText) {
|
||||||
|
|
||||||
if (Pattern.matches(fpRegex, pText))
|
if (fpPattern.matcher(pText).matches())
|
||||||
try {
|
try {
|
||||||
return Double.parseDouble(pText);
|
return Double.parseDouble(pText);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
|
Loading…
Reference in New Issue