This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] for Review: BufferedReader and InputStreamReader Optimizations


Hi People,

>	* java/io/BufferedReader.java (sbuf): New field.

>   /**
>+   * The line buffer for <code>readLine</code>.
>+   */
>+  private StringBuffer sbuf = null;

>-    StringBuffer sbuf = new StringBuffer(200);
>+    if (sbuf == null)
>+      sbuf = new StringBuffer(200);
>+    else
>+      sbuf.setLength(0);

BufferedReader.readLine() was never synchronized so in
the pre-patch code, the StringBuffer is local whereas it
is an instance field in the post-patch code. I don't know
whether it is allowable or makes sense for a BufferedReader
to be concurrently used across multiple threads. It would
appear to me that readLine() would be unreliable with a
shared BufferedReader in either case, but the post-patch
case seems even more unreliable....

-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]