8229022: BufferedReader performance can be improved by using StringBuilder
Reviewed-by: igerasim, vtewari, dfuchs
--- 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);
}
}