[11u] RFR (XS) 8229022: BufferedReader performance can be improved by using StringBuilder
Langer, Christoph
christoph.langer at sap.com
Mon Oct 7 14:33:05 UTC 2019
Hi Aleksey,
this looks good to me.
Best regards
Christoph
> -----Original Message-----
> From: jdk-updates-dev <jdk-updates-dev-bounces at openjdk.java.net> On
> Behalf Of Aleksey Shipilev
> Sent: Freitag, 4. Oktober 2019 16:15
> To: jdk-updates-dev at openjdk.java.net
> Subject: [11u] RFR (XS) 8229022: BufferedReader performance can be
> improved by using StringBuilder
>
> RFE:
> https://bugs.openjdk.java.net/browse/JDK-8229022
> https://hg.openjdk.java.net/jdk/jdk/rev/ed0058d06107
>
> This is a tiny RFE that does substantial performance improvement. The patch
> does not apply cleanly,
> because the context is a bit different. (Mostly because JDK-823042
> LineNumberReader fixes, which I
> have questions about, so it is not really backportable at the moment).
>
> 11u patch:
>
> --- old/src/java.base/share/classes/java/io/BufferedReader.java 2019-
> 10-04 16:09:45.826490807 +0200
> +++ new/src/java.base/share/classes/java/io/BufferedReader.java 2019-
> 10-04 16:09:45.674492392 +0200
> @@ -312,7 +312,7 @@
> * @exception IOException If an I/O error occurs
> */
> String readLine(boolean ignoreLF) throws IOException {
> - StringBuffer s = null;
> + StringBuilder s = null;
> int startChar;
>
> synchronized (lock) {
> @@ -368,7 +368,7 @@
> }
>
> if (s == null)
> - s = new StringBuffer(defaultExpectedLineLength);
> + s = new StringBuilder(defaultExpectedLineLength);
> s.append(cb, startChar, i - startChar);
> }
> }
>
> Testing: tier1, tier2
>
> --
> Thanks,
> -Aleksey
More information about the jdk-updates-dev
mailing list