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

Paul Sandoz paul.sandoz at oracle.com
Wed Feb 5 19:09:08 UTC 2014


On Feb 5, 2014, at 6:58 PM, Xueming Shen <xueming.shen at oracle.com> wrote:

> Hi,
> 
> Let's try to wrap it up, otherwise I may drop the ball somewhere :-)
> 
> On 01/22/2014 07:20 AM, Paul Sandoz wrote:
>> 
>> 
>>> 
>> if (lang == "tr" || lang == "az" || lang == "lt") {
>>   // local dependent
>>   return toLowerCaseEx(result, firstUpper, locale, true);
>> }
>> // otherwise false is passed to subsequent calls to toLowerCaseEx
>> 
>> ?
>> 
> 
> toLowerCaseEx will also be invoked later (in your another suggestion next), which
> needs a "localeDependent".
> 

But is not the second call to toLowerCaseEx always invoked with a value of false?

2574         String lang = locale.getLanguage();
2575         final boolean localeDependent = (lang == "tr" || lang == "az" || lang == "lt");
2576         if (localeDependent) {
2577             return toLowerCaseEx(result, firstUpper, locale, localeDependent);  // <-- localeDependent is true
2578         }
2579         for (int i = firstUpper; i < len; i++) {
2580             int c = (int)value[i];
2581             if (c >= Character.MIN_HIGH_SURROGATE && c <= Character.MAX_HIGH_SURROGATE ||
2582                 c == '\u03A3' ||      // GREEK CAPITAL LETTER SIGMA
2583                 (c = Character.toLowerCase(c)) >= Character.MIN_SUPPLEMENTARY_CODE_POINT) {
2584                 return toLowerCaseEx(result, i, locale, localeDependent);  // <-- localDependent is false
2585             }
2586             result[i] = (char)c;
2587         }
2588         return new String(result, true);


<snip>
> Given the measurement indicates it does not bring in measurable
> improvement, personally I would prefer to keep the existing one,
> if you don't have a very strong opinion on this.
> 

No i don't have a strong opinion.

Paul.


> http://cr.openjdk.java.net/~sherman/8032012/
> 
> Thanks!
> -Sherman
> 
> 



More information about the core-libs-dev mailing list