RFR (S): 8065070: (fmt) Avoid creating substrings when building FormatSpecifier

Claes Redestad claes.redestad at oracle.com
Sun Nov 16 23:09:53 UTC 2014


can I have a review for this small optimization to j.u.Formatter which 
removes a number of
String allocationswhen parsing format specifiers:


Testing: jtreg

Reasonable improvement (~5-20%) when microbenchmarking String.format 
expressions with index,
precision and/or width specifiers. Example:

public String formatIndexedDoubleExpr() {
     return String.format("%1$2.3f", pi);

before: 1082.564   18.943  ops/ms
after: 1309.945   18.219  ops/ms  # 1.21x



More information about the core-libs-dev mailing list