Rewrite of IBM doublebyte charsets

Ulf Zibis Ulf.Zibis at gmx.de
Tue May 12 22:45:56 UTC 2009


Am 12.05.2009 21:03, Xueming Shen schrieb:
> Ulf Zibis wrote:
>>>>
>>>> *** Question: Why you code:
>>>>
>>>>                   } else if ((byte1 & MSB) == 0) {  // ASCII  G0
>>>>
>>>> instead of:
>>>>
>>>>                   } else if (byte1 >= 0) {  // ASCII  G0
>>>>
>>> I believe this line was written 10 years ago, so I have no idea (or 
>>> forgot) why we picked this one, my guess is the code might
>>> be a little easier to read with "MSB"...you think the >=0 is better 
>>> or faster/
>>
>> Yes, I think it's also faster, as loading of "MSB" + AND would be saved.
>> Not sure if HotSpot will detect the shortcut!
>>
>
> it actually should be "byte1 < 0x80"
>

Oops, you are right. I was in the assumption, that byte1 was, "naked" 
from byte array, in range 0xffffff80..0x7f.
Maybe it's better to do:
    byte byte1 = sa[sp];
or mask by 0xff after the if .. else

... so we could save some more loop effective opcode by "byte1 >= 0"


-Ulf





More information about the core-libs-dev mailing list