Progress of patches
Martin Buchholz
martinrb at google.com
Thu Mar 11 19:56:05 UTC 2010
On Thu, Mar 11, 2010 at 10:25, Ulf Zibis <Ulf.Zibis at gmx.de> wrote:
> Am 11.03.2010 05:42, schrieb Martin Buchholz:
>>
>> I couldn't resist making a similar change to isValidCodePoint.
>>
>> @@ -2678,7 +2678,8 @@
>> * @since 1.5
>> */
>> public static boolean isValidCodePoint(int codePoint) {
>> - return codePoint>= MIN_CODE_POINT&& codePoint<= MAX_CODE_POINT;
>> + int plane = codePoint>>> 16;
>> + return plane< ((MAX_CODE_POINT + 1)>>> 16);
>> }
>>
>> /**
>>
>> This is a more important optimization, since isValidCodePoint
>> almost always requires two compares, and this reduces it to one.
>>
>
> Why isn't this true for isSupplementaryCodePoint() too ?
> Particularly there the "cheap" compare against 0 can't be benefited.
Because almost all code points are actually BMP,
the naive implementation of isValidCodePoint will
almost always require one more branch than
isSupplementaryCodePoint,
making it more valuable to optimize.
>> (Still, none of these are really important, and no one will notice)
Martin
More information about the core-libs-dev
mailing list