提交 e65ad6f4 编写于 作者: M mchung

6799689: Make sun.misc.FloatingDecimal.hexFloatPattern static field initialized lazily

Summary: Lazily initialize the hexFloatPattern static field
Reviewed-by: darcy
上级 7cde326a
...@@ -1867,10 +1867,16 @@ public class FloatingDecimal{ ...@@ -1867,10 +1867,16 @@ public class FloatingDecimal{
* Grammar is compatible with hexadecimal floating-point constants * Grammar is compatible with hexadecimal floating-point constants
* described in section 6.4.4.2 of the C99 specification. * described in section 6.4.4.2 of the C99 specification.
*/ */
private static Pattern hexFloatPattern = Pattern.compile( private static Pattern hexFloatPattern = null;
private static synchronized Pattern getHexFloatPattern() {
if (hexFloatPattern == null) {
hexFloatPattern = Pattern.compile(
//1 234 56 7 8 9 //1 234 56 7 8 9
"([-+])?0[xX](((\\p{XDigit}+)\\.?)|((\\p{XDigit}*)\\.(\\p{XDigit}+)))[pP]([-+])?(\\p{Digit}+)[fFdD]?" "([-+])?0[xX](((\\p{XDigit}+)\\.?)|((\\p{XDigit}*)\\.(\\p{XDigit}+)))[pP]([-+])?(\\p{Digit}+)[fFdD]?"
); );
}
return hexFloatPattern;
}
/* /*
* Convert string s to a suitable floating decimal; uses the * Convert string s to a suitable floating decimal; uses the
...@@ -1880,7 +1886,7 @@ public class FloatingDecimal{ ...@@ -1880,7 +1886,7 @@ public class FloatingDecimal{
static FloatingDecimal parseHexString(String s) { static FloatingDecimal parseHexString(String s) {
// Verify string is a member of the hexadecimal floating-point // Verify string is a member of the hexadecimal floating-point
// string language. // string language.
Matcher m = hexFloatPattern.matcher(s); Matcher m = getHexFloatPattern().matcher(s);
boolean validInput = m.matches(); boolean validInput = m.matches();
if (!validInput) { if (!validInput) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册