Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI [v7]

2023-02-22 Thread Eirik Bjorsnos
On Wed, 22 Feb 2023 16:10:42 GMT, Martin Buchholz wrote: >> 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') { >>

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI [v7]

2023-02-22 Thread Martin Buchholz
On Wed, 22 Feb 2023 07:12:35 GMT, Eirik Bjorsnos wrote: >>> 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

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI [v7]

2023-02-21 Thread Eirik Bjorsnos
On Wed, 22 Feb 2023 00:50:39 GMT, Martin Buchholz 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. > >>

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI [v7]

2023-02-21 Thread Martin Buchholz
On Wed, 22 Feb 2023 00:45:52 GMT, Martin Buchholz wrote: >> There are still some books on this :) but from wikipedia: >>> during May 1963 the CCITT Working Party on the New Telegraph Alphabet >>> proposed to assign lowercase characters to >>>

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI [v7]

2023-02-21 Thread Martin Buchholz
On Wed, 22 Feb 2023 00:06:51 GMT, David Holmes wrote: >> Thanks Martin, I will from now on envision a stack of dusty punch cards with >> carefully scribbled notes on the back, barely held together with a dry and >> cracked rubber band. >> >> More to the point: Do you have an opinion on the

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI [v7]

2023-02-21 Thread David Holmes
On Tue, 21 Feb 2023 23:28:52 GMT, Eirik Bjorsnos wrote: >> More to the point, ASCII was obviously **designed** to allow you to >> uppercase a lower case letter with a single instruction, so "the book" might >> have been a draft standard before they scrubbed out the interesting history! > >

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI [v7]

2023-02-21 Thread Eirik Bjorsnos
On Tue, 21 Feb 2023 23:20:03 GMT, Martin Buchholz wrote: >> "oldest trick in the book" is a phrase that does not necessarily imply >> existence of an actual book! >> >> Let this evoke an image of a **personal** book of tricks that programmers in >> the 1960s might have recorded such

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI [v7]

2023-02-21 Thread Martin Buchholz
On Tue, 21 Feb 2023 20:48:04 GMT, Martin Buchholz wrote: >> Perhaps @Martin-Buchholz could chime in and also tell us which book he found >> his ASCII trick in :) > > "oldest trick in the book" is a phrase that does not necessarily imply > existence of an actual book! > > Let this evoke an

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI [v7]

2023-02-21 Thread Eirik Bjorsnos
On Tue, 21 Feb 2023 14:22:30 GMT, Alan Bateman wrote: >> Eirik Bjorsnos has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Remove whitespace following '(' > > src/java.base/share/classes/java/lang/CharacterDataLatin1.java.template line >

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI [v7]

2023-02-21 Thread Martin Buchholz
On Tue, 21 Feb 2023 20:33:41 GMT, Eirik Bjorsnos wrote: >> Hi Alan, >> >> I thought I was clever by encoding the 'uppercaseness' in the variable name, >> but yeah I'll find a better name :) >> >> There is some precedent for using the 'ASCII trick' comment in the JDK. I >> found it in

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI [v7]

2023-02-21 Thread Eirik Bjorsnos
On Tue, 21 Feb 2023 20:23:11 GMT, Eirik Bjorsnos wrote: >> src/java.base/share/classes/java/lang/CharacterDataLatin1.java.template line >> 175: >> >>> 173: } >>> 174: // uppercase b1 using 'the oldest ASCII trick in the book' >>> 175: int U = b1 & 0xDF; >> >> I'm

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI [v7]

2023-02-21 Thread Eirik Bjorsnos
On Tue, 21 Feb 2023 14:27:03 GMT, Alan Bateman wrote: >> Eirik Bjorsnos has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Remove whitespace following '(' > > src/java.base/share/classes/java/lang/CharacterDataLatin1.java.template line >

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI [v7]

2023-02-21 Thread Alan Bateman
On Tue, 21 Feb 2023 11:14:13 GMT, Eirik Bjorsnos wrote: >> This PR suggests we can speed up `StringLatin1.regionMatchesCI` by applying >> 'the oldest ASCII trick in the book'. >> >> The new static method `CharacterDataLatin1.equalsIgnoreCase` compares two >> latin1 bytes for equality ignoring

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI [v7]

2023-02-21 Thread Claes Redestad
On Tue, 21 Feb 2023 11:14:13 GMT, Eirik Bjorsnos wrote: >> This PR suggests we can speed up `StringLatin1.regionMatchesCI` by applying >> 'the oldest ASCII trick in the book'. >> >> The new static method `CharacterDataLatin1.equalsIgnoreCase` compares two >> latin1 bytes for equality ignoring

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI [v7]

2023-02-21 Thread Eirik Bjorsnos
> This PR suggests we can speed up `StringLatin1.regionMatchesCI` by applying > 'the oldest ASCII trick in the book'. > > The new static method `CharacterDataLatin1.equalsIgnoreCase` compares two > latin1 bytes for equality ignoring case. `StringLatin1.regionMatchesCI` is > updated to use