A few char-fiddling optimizations for Pattern.java

Ulf Zibis Ulf.Zibis at gmx.de
Fri Apr 16 00:23:39 UTC 2010


>
> Hi Xueming and Ulf,
>
> Please review a few more optimizations to be added to the
> current crop:
>
> http://cr.openjdk.java.net/~martin/webrevs/openjdk7/Pattern-opt/
>
>    

Have you tried to disassemble? :

     private static final boolean isSupplementary(int cp) {
          returnCharacter.isSurrogate((char)cp)  ||
//  in this case method should be namedisSupplementaryOrHigher():
//                cp>= Character.MIN_SUPPLEMENTARY_CODE_POINT);
                  Character.isSupplementaryCodePoint(cp);

     }

Maybe HotSpot would compile to same code.
Anyway I think, such functionality should belong to class Character.
And don't forget the 8-space indentation rule for line continuation. ;-)


Use Character.codePointCount(...) instead ;-)  :

countCodePoints(CharSequence seq)


-Ulf










More information about the core-libs-dev mailing list