RFR: 8302871: Speed up StringLatin1.regionMatchesCI

2023-02-20 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 `equalsIgnoreCase

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI

2023-02-20 Thread Eirik Bjorsnos
On Sat, 18 Feb 2023 09:21:25 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 case.

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI

2023-02-20 Thread David Schlosnagle
On Sat, 18 Feb 2023 09:21:25 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 case.

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI

2023-02-20 Thread Eirik Bjorsnos
On Sat, 18 Feb 2023 19:04:24 GMT, David Schlosnagle 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 ignori

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI

2023-02-20 Thread David Schlosnagle
On Sat, 18 Feb 2023 19:45:34 GMT, Eirik Bjorsnos wrote: >> src/java.base/share/classes/java/lang/CharacterDataLatin1.java.template line >> 181: >> >>> 179: return ( U <= 'Z' // In range A-Z >>> 180: || (U >= 0xC0 && U <= 0XDE && U != 0xD7)) // ..or >>> A-grave-Thorn,

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

2023-02-20 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 `equa

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

2023-02-20 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 `equa

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

2023-02-20 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 `equa

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

2023-02-20 Thread Claes Redestad
On Mon, 20 Feb 2023 14:45:09 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 [v4]

2023-02-20 Thread Eirik Bjorsnos
On Mon, 20 Feb 2023 15:40:09 GMT, Claes Redestad wrote: >> Eirik Bjorsnos has updated the pull request incrementally with two >> additional commits since the last revision: >> >> - Add @bug tag to EqualsIgnoreCase test for correct issue JDK-8302871 >> - Add @bug tag to EqualsIgnoreCase test f

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

2023-02-20 Thread Claes Redestad
On Mon, 20 Feb 2023 16:16:45 GMT, Eirik Bjorsnos wrote: >> src/java.base/share/classes/java/lang/CharacterDataLatin1.java.template line >> 170: >> >>> 168: * @return true if the two bytes are considered equals ignoring >>> case in latin1 >>> 169: */ >>> 170: static boolean equal

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

2023-02-20 Thread Eirik Bjorsnos
On Mon, 20 Feb 2023 16:23:32 GMT, Claes Redestad wrote: >> Is it not already in CharacterDataLatin1? >> >> Here is a comparison of relying on improvements in >> `CharacterDataLatin1.toUpperCase/toLowerCase` only vs. using >> `CharacterDataLatin1.equalsIgnoreCase`: >> >> Character.toUpperCase/

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

2023-02-20 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 `equa

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

2023-02-20 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 `equa

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 `equa

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 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 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 > 1

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 sur

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 ZipFile

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

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 `equa

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 > 1

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

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 `equa

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 imag

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 techniques

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! > > Than

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 app

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 >>> sticks[[a]](https://en.wikipedia.org/wiki/ASCII#cite

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

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 `equa

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. > >> Do

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

2023-02-22 Thread Claes Redestad
On Wed, 22 Feb 2023 07:11:16 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-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 expla

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

2023-02-22 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 `equa

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

2023-02-22 Thread Martin Buchholz
On Wed, 22 Feb 2023 07:11:16 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-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') { >> retu

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

2023-02-22 Thread Eirik Bjorsnos
On Wed, 22 Feb 2023 16:25:41 GMT, Martin Buchholz wrote: >> Eirik Bjorsnos has updated the pull request incrementally with two >> additional commits since the last revision: >> >> - Replace 'oldest ASCII trick in the book' use in toUpperCase, toLowerCase >> with "by removing (setting) a singl

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

2023-02-22 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 `equa

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

2023-02-22 Thread Eirik Bjorsnos
On Wed, 22 Feb 2023 16:37:45 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 [v13]

2023-02-22 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 `equa

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

2023-02-22 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 `equa

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

2023-02-22 Thread Eirik Bjorsnos
On Wed, 22 Feb 2023 20:01:52 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 [v14]

2023-02-22 Thread Eirik Bjorsnos
On Thu, 23 Feb 2023 07:21:08 GMT, Eirik Bjorsnos wrote: > Seems compatibility with existing 6-bit devices might have been the primary > concern: This also explains the placement of brackets, braces, bars, tilde etc. They would look visually similar on 6-bit devices: https://user-images.github

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

2023-02-23 Thread Alan Bateman
On Wed, 22 Feb 2023 18:44:57 GMT, Eirik Bjorsnos wrote: > I'll let this linger a bit before integrating in case Alan has comments after > the latest updates. I plan to look at it, been busy with other things. - PR: https://git.openjdk.org/jdk/pull/12632

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

2023-02-23 Thread Eirik Bjorsnos
On Wed, 22 Feb 2023 20:01:52 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 [v14]

2023-02-24 Thread Alan Bateman
On Wed, 22 Feb 2023 20:01:52 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