提交 afc47100 编写于 作者: O olagneau

7050528: Improve performance of java.text.DecimalFormat.format() call stack

Reviewed-by: darcy
上级 7d09db22
/*
* Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -286,10 +286,21 @@ public abstract class NumberFormat extends Format {
* @see java.text.Format#format
*/
public final String format(double number) {
// Use fast-path for double result if that works
String result = fastFormat(number);
if (result != null)
return result;
return format(number, new StringBuffer(),
DontCareFieldPosition.INSTANCE).toString();
}
/*
* fastFormat() is supposed to be implemented in concrete subclasses only.
* Default implem always returns null.
*/
String fastFormat(double number) { return null; }
/**
* Specialization of format.
* @exception ArithmeticException if rounding is needed with rounding
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册