<i18n dev> RFR: 8302871: Speed up StringLatin1.regionMatchesCI [v7]

Eirik Bjorsnos duke at openjdk.org
Wed Feb 22 07:15:44 UTC 2023


On Wed, 22 Feb 2023 00:50:39 GMT, Martin Buchholz <martin at openjdk.org> wrote:

>> More history: IIRC I originally used 'ASCII trick' when I was truly only cared about ASCII, not Latin1 (e.g. ZipFile.isMetaName) and it's a slight misnomer to use "ASCII" here.  But Latin1 followed the precedent of ASCII.
>
>> Do you have an opinion on the appropriate level of documentation / comments for this kind of 'tricky' code? 
> 
> This code is not that tricky!  And the proposed level of documentation is excessive!  A couple of lines of explanation and perhaps a link to an external document would be good.
> 
> It often happens to me that I will write such exhaustive notes for myself when learning a new technology.  A year later I pare it all back because much of it is "obvious in retrospect".

Thanks Martin, David, Alan.  This was instructive (and fun!)

I suggest we condense the comment to something like this:


// Uppercase b1 by removing a single bit
int upper = b1 & 0xDF;
if (upper < 'A') {
    return false;  // Low ASCII
}
...


The similar methods `toLowerCase` `toUpperCase` just above have been updated to follow the same style. (I also updated local variable names there to align better with equalsIgnoreCase)

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

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


More information about the i18n-dev mailing list