Progress of patches
Martin Buchholz
martinrb at google.com
Thu Mar 11 04:42:09 UTC 2010
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