提交 eae4fc04 编写于 作者: B bpb

8229022: BufferedReader performance can be improved by using StringBuilder

Reviewed-by: igerasim, vtewari, dfuchs
上级 0069ca29
...@@ -310,7 +310,7 @@ public class BufferedReader extends Reader { ...@@ -310,7 +310,7 @@ public class BufferedReader extends Reader {
* @exception IOException If an I/O error occurs * @exception IOException If an I/O error occurs
*/ */
String readLine(boolean ignoreLF) throws IOException { String readLine(boolean ignoreLF) throws IOException {
StringBuffer s = null; StringBuilder s = null;
int startChar; int startChar;
synchronized (lock) { synchronized (lock) {
...@@ -366,7 +366,7 @@ public class BufferedReader extends Reader { ...@@ -366,7 +366,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);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册