Optimize Formatter.parse (including String.printf)

Xueming Shen Xueming.Shen at Sun.COM
Thu Nov 5 07:07:38 UTC 2009


#2659:

conversion(m.group(idx++));

->  conversion(m.group(idx)); ?


The rest looks fine.

sherman


Martin Buchholz wrote:
> Hi Sherman,
>
> I'd like you to do a code review.
>
> http://cr.openjdk.java.net/~martin/webrevs/openjdk7/Formatter.parse/ 
> <http://cr.openjdk.java.net/%7Emartin/webrevs/openjdk7/Formatter.parse/>
>
> Synopsis: Optimize Formatter.parse (including String.printf)
> Description:
> Formatter is not as efficient as it could be.
> Here's a low-hanging fruit optimization
> that creates fewer objects,
> and uses the idiom
> return al.toArray(new FormatString[al.size()]);
>   
> I'm sure additional optimizations are possible.
>
> Results: about 10-20% faster on in-house microbenchmarks of
> String.printf
>
> Martin




More information about the core-libs-dev mailing list