<i18n dev> RFR: 8263677: Improve Character.isLowerCase/isUpperCase lookups

Roger Riggs rriggs at openjdk.java.net
Tue Mar 16 20:23:10 UTC 2021


On Tue, 16 Mar 2021 12:51:02 GMT, Claes Redestad <redestad at openjdk.org> wrote:

> This patch changes the otherLowercase / otherUppercase bits to be set if either the codepoint is of type LOWERCASE_LETTER and UPPERCASE_LETTER, or the Unicode Other_Lowercase / Other_Uppercase property is set. This simplifies the lookup in Character.isLowerCase/isUpperCase to a single table lookup, which appears to be healthy for performance.
> 
> I also took the opportunity to clean up the somewhat dated GenerateCharacter utility class.
> 
> Testing: tier1-3

make/jdk/src/classes/build/tools/generatecharacter/GenerateCharacter.java line 310:

> 308:     {
> 309:         long[] result;
> 310:         if (bLatin1) {

perhaps shorten to:
final long[] result = new long[bLatin1 ? 256 : 1 << 16];

make/jdk/src/classes/build/tools/generatecharacter/GenerateCharacter.java line 652:

> 650:             // There is no block just like it already, so add it to
> 651:             // the buffer and put its index into the new map.
> 652:             if (m >= 0) System.arraycopy(map, i, buffer, ptr, m);

If m == 0, you could skip the arraycopy.

make/jdk/src/classes/build/tools/generatecharacter/GenerateCharacter.java line 659:

> 657:         // so create a new array and copy data from the temporary buffer.
> 658:         long[] newdata = new long[ptr];
> 659:         if (ptr >= 0) System.arraycopy(buffer, 0, newdata, 0, ptr);

ditto, if ptr == 0, skip the arraycopy

make/jdk/src/classes/build/tools/generatecharacter/GenerateCharacter.java line 1588:

> 1586:         StringBuffer desc = new StringBuffer("java GenerateCharacter");
> 1587:         for (String arg : args) {
> 1588:             desc.append(" " + arg);

Avoid string concat:  
   desc.append(' ').append(arg);

-------------

PR: https://git.openjdk.java.net/jdk/pull/3028


More information about the i18n-dev mailing list