15
15
*/
16
16
public class FastDoubleParser {
17
17
18
+ private static final DoubleBitsFromCharArray CHAR_ARRAY_PARSER = new DoubleBitsFromCharArray ();
19
+ private static final DoubleBitsFromCharSequence CHAR_SEQ_PARSER = new DoubleBitsFromCharSequence ();
18
20
19
21
/**
20
22
* Don't let anyone instantiate this class.
@@ -47,7 +49,7 @@ public static double parseDouble(CharSequence str) throws NumberFormatException
47
49
* @throws NumberFormatException if the string can not be parsed
48
50
*/
49
51
public static double parseDouble (CharSequence str , int offset , int length ) throws NumberFormatException {
50
- long bitPattern = new DoubleBitsFromCharSequence () .parseFloatingPointLiteral (str , offset , length );
52
+ long bitPattern = CHAR_SEQ_PARSER .parseFloatingPointLiteral (str , offset , length );
51
53
if (bitPattern == AbstractFloatValueParser .PARSE_ERROR ) {
52
54
throw new NumberFormatException ("Illegal input" );
53
55
}
@@ -79,7 +81,7 @@ public static double parseDouble(char[] str) throws NumberFormatException {
79
81
* @throws NumberFormatException if the string can not be parsed
80
82
*/
81
83
public static double parseDouble (char [] str , int offset , int length ) throws NumberFormatException {
82
- long bitPattern = new DoubleBitsFromCharArray () .parseFloatingPointLiteral (str , offset , length );
84
+ long bitPattern = CHAR_ARRAY_PARSER .parseFloatingPointLiteral (str , offset , length );
83
85
if (bitPattern == AbstractFloatValueParser .PARSE_ERROR ) {
84
86
throw new NumberFormatException ("Illegal input" );
85
87
}
@@ -109,7 +111,7 @@ public static double parseDouble(char[] str, int offset, int length) throws Numb
109
111
* otherwise, {@code -1L}.
110
112
*/
111
113
public static long parseDoubleBits (CharSequence str , int offset , int length ) {
112
- return new DoubleBitsFromCharSequence () .parseFloatingPointLiteral (str , offset , length );
114
+ return CHAR_SEQ_PARSER .parseFloatingPointLiteral (str , offset , length );
113
115
}
114
116
115
117
/**
@@ -128,6 +130,6 @@ public static long parseDoubleBits(CharSequence str, int offset, int length) {
128
130
* otherwise, {@code -1L}.
129
131
*/
130
132
public static long parseDoubleBits (char [] str , int offset , int length ) {
131
- return new DoubleBitsFromCharArray () .parseFloatingPointLiteral (str , offset , length );
133
+ return CHAR_ARRAY_PARSER .parseFloatingPointLiteral (str , offset , length );
132
134
}
133
135
}
0 commit comments