On Wed, 15 Mar 2023 12:07:12 GMT, Sergey Tsypanov <stsypa...@openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/CharacterData.java line 72:
>> 
>>> 70: 
>>> 71:     static final CharacterData of(int ch) {
>>> 72:         if (ch >= 0 && ch <= 0xFF) {     // fast-path
>> 
>> Maybereducing to a single branch with a mask op helps further? Or maybe the 
>> JIT already effectively does that:
>> 
>> `if (ch && 0xFFFFFF00 == 0) {`
>
> Btw, I think we can do the same for `StringLatin1.canEncode()`

It seems reasonable to keep these two in sync, yes. (`CharacterData.of` could 
even call into `StringLatin1.canEncode`, unless that's cause for some 
performance anomaly)

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

PR: https://git.openjdk.org/jdk/pull/13040

Reply via email to