review request for 6798511/6860431: Include functionality of Surrogate in Character

Ulf Zibis Ulf.Zibis at gmx.de
Wed Mar 17 09:11:56 UTC 2010


Am I mad ???

2nd. correction:

But
         for (int i = offset; i < offset + count; i++) {
             int c = codePoints[i];
             char plane = (char)(c >>> 16);
             if (plane == 0)
                 n += 1;
             else if (plane < 0x11)
                 n += 2;
             else throw new IllegalArgumentException(Integer.toString(c));
         }
has too only 2 branches and additionally could benefit from tiny 16-bit 
comparisons.
The shift additionally could be omitted on CPU's which can benefit from 
6933327.

Instead:
         for (int i = offset; i < offset + count; i++) {
             int c = codePoints[i];
             if (c >= Character.MIN_VALUE &&
                 c <=  Character.MAX_VALUE)
                 n += 1;
             else if (c >= Character.MIN_SUPPLEMENTARY_CODE_POINT &&
                 c <=  Character.MAX_SUPPLEMENTARY_CODE_POINT)
                 n += 2;
             else throw new IllegalArgumentException(Integer.toString(c));
         }
needs 4 branches and 4 32-bit comparisons.

-Ulf






More information about the core-libs-dev mailing list