String.lastIndexOf confused by unpaired trailing surrogate
Martin Buchholz
martinrb at google.com
Thu Mar 25 23:59:05 UTC 2010
On Thu, Mar 25, 2010 at 09:18, Ulf Zibis <Ulf.Zibis at gmx.de> wrote:
> Am 24.03.2010 08:32, schrieb Martin Buchholz:
>>
>> Hi Ulf,
>>
>> You have this interesting optimization:
>>
>> public static boolean isSurrogate(char ch) {
>> - return ch>= MIN_SURROGATE&& ch< MAX_SURROGATE + 1;
>> + return (ch -= MIN_SURROGATE)>= 0&& ch< MAX_SURROGATE + 1 -
>> MIN_SURROGATE;
>> }
>>
>> Do you have any evidence that hotspot can produce better code from this,
>> or that there is a measurable performance improvement?
>> Or was this just an experiment?
>>
>
> If isHighSurrogate and isSurrogate are used consecutive on same char, result
> of ch -= MIN_SURROGATE could be used for both.
> If isLowSurrogate and isSurrogate are used consecutive on same char, result
> of ch -= MAX_SURROGATE would fit better.
> If isHighSurrogate and isLowSurrogate are used consecutive on same char,
> result of ch -= MIN_LOW_SURROGATE would fit better.
It seems to me that you get the same opportunities for constant-folding.
Are you suggesting that there are x86 instructions that could be
more efficient if they have an argument value of MAX_SURROGATE-MIN_SURROGATE
than if they had an argument value of MAX_SURROGATE?
Martin
> I suggest using 1st pair in JDK library.
>
> -Ulf
>
>
>
More information about the core-libs-dev
mailing list