RFR: JDK-8032012, , String.toLowerCase/toUpperCase performance improvement
Paul Sandoz
paul.sandoz at oracle.com
Mon Jan 20 17:24:39 UTC 2014
On Jan 16, 2014, at 7:08 PM, Xueming Shen <xueming.shen at oracle.com> wrote:
> Hi,
>
> The proposed changeset is to improve the performance (both speed and memory
> usage) of String.toLowerCase/toUpperCase, by
>
> (1) to separate the "most likely" use scenario (non supplementary character, no special
> case mapping handling) into simple/quick iteration loop code path
> (2) to use the package private constructor String(char[], boolean) to avoid unnecessary
> target char[] copy in fast-path case.
> (3) some tiny code cleanup.
>
> Since it's supposed to be a simple/quick round of code cleanup, I did not go too far to
> optimize the supplementary/special mapping code.
>
> The webrev is
>
> http://cr.openjdk.java.net/~sherman/8032012/
>
Some quick comments.
In String.toLowerCase:
- it would be nice to get rid of the pseudo goto using the "scan" labelled block.
- there is no need for the "localeDependent" local variable.
- you might be able to optimize by doing (could depend on the answer to the next point):
int c = (int)value[i];
int lc = Character.toLowerCase(c);
if (.....) { result[i] = (char)lc; } else { return toLowerCaseEx(result, i, locale, localeDependent); }
- Do you need to check ERROR for the result of toLowerCase?
2586 if (c == Character.ERROR ||
Paul.
More information about the core-libs-dev
mailing list