8229022: BufferedReader performance can be improved by using StringBuilder

Reviewed-by: igerasim, vtewari, dfuchs
This commit is contained in:
Brian Burkhalter 2019-10-02 07:50:06 -07:00
parent 85a62dcc5c
commit c1b844a225

View File

@ -314,7 +314,7 @@ public class BufferedReader extends Reader {
* @throws IOException If an I/O error occurs * @throws IOException If an I/O error occurs
*/ */
String readLine(boolean ignoreLF, boolean[] term) throws IOException { String readLine(boolean ignoreLF, boolean[] term) throws IOException {
StringBuffer s = null; StringBuilder s = null;
int startChar; int startChar;
synchronized (lock) { synchronized (lock) {
@ -372,7 +372,7 @@ public class BufferedReader extends Reader {
} }
if (s == null) if (s == null)
s = new StringBuffer(defaultExpectedLineLength); s = new StringBuilder(defaultExpectedLineLength);
s.append(cb, startChar, i - startChar); s.append(cb, startChar, i - startChar);
} }
} }