RFR: JDK-8032012, , String.toLowerCase/toUpperCase performance improvement

Vitaly Davidovich vitalyd at gmail.com
Fri Feb 7 14:58:03 UTC 2014

I think JIT handles trivial loops with break fine.  One issue here though
is the overall method size and complexity (esp if some other methods are
inlined into it).  If the first loop represents a common/fast path (no
surrogates and string already lower case) then I'd move the rest of the
code out of line into a separate method.  The only question is whether
absence of upper case is really the common case; I've certainly seen a ton
of code calling toLowerCase "just in case" where the vast majority, if not
all, of the strings are already lower cased.

Sent from my phone
On 02/07/2014 01:30 PM, Ulf Zibis wrote:

> Am 06.02.2014 18:40, schrieb Xueming Shen:
>> Are we good enough to go? :-) While it took much longer than I would have
>> expected, but I'm happy with the latest result.
>> http://cr.openjdk.java.net/~sherman/8032012/webrev/
> Except "if (first >= len)" instead "if (first = len)" I'm with you.
> -Ulf
Hi Ulf,
if the JIT is not able to fold
  for(;i<len;) {
     // may call break in the body
  if (i == len) {
    // ...

given that it's a common pattern,
i think it's better to improve the JIT that to change the code.


More information about the core-libs-dev mailing list