8229022: BufferedReader performance can be improved by using StringBuilder
authorbpb
Wed, 02 Oct 2019 07:50:06 -0700
changeset 58443 ed0058d06107
parent 58442 299756f23687
child 58444 0aa2cdae73ce
8229022: BufferedReader performance can be improved by using StringBuilder Reviewed-by: igerasim, vtewari, dfuchs
src/java.base/share/classes/java/io/BufferedReader.java
--- a/src/java.base/share/classes/java/io/BufferedReader.java	Wed Oct 02 16:08:02 2019 +0200
+++ b/src/java.base/share/classes/java/io/BufferedReader.java	Wed Oct 02 07:50:06 2019 -0700
@@ -314,7 +314,7 @@
      * @throws     IOException  If an I/O error occurs
      */
     String readLine(boolean ignoreLF, boolean[] term) throws IOException {
-        StringBuffer s = null;
+        StringBuilder s = null;
         int startChar;
 
         synchronized (lock) {
@@ -372,7 +372,7 @@
                 }
 
                 if (s == null)
-                    s = new StringBuffer(defaultExpectedLineLength);
+                    s = new StringBuilder(defaultExpectedLineLength);
                 s.append(cb, startChar, i - startChar);
             }
         }