This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: [PATCH] for Review: BufferedReader and InputStreamReader Optimizations
- From: Mohan Embar <gnustuff at thisiscool dot com>
- To: GCJ Patches <java-patches at gcc dot gnu dot org>
- Date: Tue, 06 Jan 2004 11:59:53 -0600
- Subject: Re: [PATCH] for Review: BufferedReader and InputStreamReader Optimizations
- Reply-to: gnustuff at thisiscool dot com
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/