RFR: 8285255: refine StringLatin1.regionMatchesCI_UTF16
Roger Riggs
rriggs at openjdk.java.net
Wed Apr 20 17:44:27 UTC 2022
On Tue, 19 Apr 2022 21:15:29 GMT, XenoAmess <duke at openjdk.java.net> wrote:
> some thoughts after watching 8285001: Simplify StringLatin1.regionMatches https://github.com/openjdk/jdk/pull/8292/
>
> if (Character.toLowerCase(u1) == Character.toLowerCase(u2)) {
> continue;
> }
>
> should be changed to
>
> if (((u1 == c1) ? CharacterDataLatin1.instance.toLowerCase(c1) : c1) == Character.toLowerCase(u2)) {
> continue;
> }
>
> as:
>
> 1. c1 is LATIN1, so CharacterDataLatin1.instance.toLowerCase seems faster.
> 2. because c1 is LATIN1, so if u1 != c1, then c1 is already lowercase, and don't need a lowercase cauculation.
The test should be able to use public string classes with selected Latin1 and utf-16 arguments.
The implementation of regionMatches will end up using the corresponding implementations.
The JMH in PR#8292 might be a start.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8308
More information about the core-libs-dev
mailing list