<i18n dev> RFR: 8304245: Speed up CharacterData.of by avoiding bit shifting in the latin1 fast-path test
Eirik Bjorsnos
duke at openjdk.org
Wed Mar 15 11:47:15 UTC 2023
By avoiding a bit shift operation for the latin1 fast-path test, we can speed up the `java.lang.CharacterData.of` method by ~25% for latin1 code points.
The latin1 test is currently implemented as `ch >>> 8 == 0`. We can replace this with `ch >= 0 && ch <= 0xFF` for a noticable performance gain (especially for ASCII chars):
This methods is called frequently by various property-determining methods in `java.lang.Character` like `isLowerCase`, `isDigit` etc, so one should expect improvements for all these methods.
Performance is tested using the `Characters.isDigit` benchmark using the digits '0' (decimal 48, in CharacterDataLatin1) and '\u0660' (decimal 1632, in CharacterData00):
Baseline:
Benchmark (codePoint) Mode Cnt Score Error Units
Characters.isDigit 48 avgt 15 0.870 ± 0.011 ns/op
Characters.isDigit 1632 avgt 15 2.168 ± 0.017 ns/op
PR:
Benchmark (codePoint) Mode Cnt Score Error Units
Characters.isDigit 48 avgt 15 0.654 ± 0.007 ns/op
Characters.isDigit 1632 avgt 15 2.032 ± 0.019 ns/op
-------------
Commit messages:
- Update copyright year
- Avoid bit shifting in the CharacterDataLatin1 fast-path
Changes: https://git.openjdk.org/jdk/pull/13040/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=13040&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8304245
Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/13040.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/13040/head:pull/13040
PR: https://git.openjdk.org/jdk/pull/13040
More information about the i18n-dev
mailing list