Progress of patches
Ulf Zibis
Ulf.Zibis at gmx.de
Thu Mar 11 17:53:43 UTC 2010
I couldn't resist too ;-) . See:
https://bugs.openjdk.java.net/attachment.cgi?id=178&action=diff
Download:
https://bugs.openjdk.java.net/attachment.cgi?id=178
Please have in mind:
- the performance advantage as pair only occurs, if isBMPCodePoint too
uses logical shift '>>>'.
- String(int[] codePoints, int offset, int count) would have to access
sun.nio.cs.Surrogate, if isBMPCodePoint doesn't exist in Character.
Hopefully you can agree all my changes,
-Ulf
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.
> (Still, none of these are really important, and no one will notice)
>
> http://cr.openjdk.java.net/~martin/webrevs/openjdk7/isSupplementaryCodePoint/
>
> Martin
>
> On Wed, Mar 10, 2010 at 17:59, Martin Buchholz<martinrb at google.com> wrote:
>
>> On Wed, Mar 10, 2010 at 09:58, Ulf Zibis<Ulf.Zibis at gmx.de> wrote:
>>
>>> Hi Martin,
>>>
>>> there wasn't enough time today, so please wait for tomorrow.
>>>
>>> In brief:
>>> - I wouldn't rename to isBMPCodePoint(), because there are many other names
>>> in Surrogate class that don't sync to Character and and a usages search in
>>> sun.nio.cs.* or where ever else could be omitted. Better add "// return
>>> Character.isBMPCodePoint(uc);" as hint for the future.
>>> - Thanks for mention me as contributor.
>>> - Doesn't the bug description include the addition of isBMPCodePoint() to
>>> class Character and the equivalent enhancement to isSupplementaryCodePoint()
>>> ?
>>>
>> Sorry, I should have included the fix to isSupplementaryCodePoint()
>> in the last fix.
>>
>> Here's the next fix:
>>
>> http://cr.openjdk.java.net/~martin/webrevs/openjdk7/isSupplementaryCodePoint/
>>
>> 6666666: A better implementation of Character.isSupplementaryCodePoint
>> Summary: Clever bit-twiddling saves a few bytes of machine code
>> Reviewed-by: sherman
>> Contributed-by: Ulf Zibis<Ulf.Zibis at gmx.de>
>> diff --git a/src/share/classes/java/lang/Character.java
>> b/src/share/classes/java/lang/Character.java
>> --- a/src/share/classes/java/lang/Character.java
>> +++ b/src/share/classes/java/lang/Character.java
>> @@ -2693,8 +2693,8 @@
>> * @since 1.5
>> */
>> public static boolean isSupplementaryCodePoint(int codePoint) {
>> - return codePoint>= MIN_SUPPLEMENTARY_CODE_POINT
>> -&& codePoint<= MAX_CODE_POINT;
>> + int plane = codePoint>>> 16;
>> + return plane != 0&& plane< ((MAX_CODE_POINT + 1)>>> 16);
>> }
>>
>> /**
>>
>>
>
>
More information about the core-libs-dev
mailing list