This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
BufferedOutputStream.write() premature buffer flush patch
- From: Mark Wielaard <mark at klomp dot org>
- To: java-patches at gcc dot gnu dot org
- Date: 13 Feb 2003 21:42:00 +0100
- Subject: BufferedOutputStream.write() premature buffer flush patch
- Organization:
Hi,
The following small patch makes sure that a BufferedOutputStream is only
flushed when really needed (which means if the buffer is full and
another byte should be written). This is more according to spec and how
other jdks do it. It probably doesn't impact that many applications (and
probably only if they depend on this feature for optimization) but it
does fix one Mauve test.
2003-02-13 Mark Wielaard <mark@klomp.org>
* java/io/BufferedOutputStream.java (write(int)): Only flush when
next byte cannot be buffered.
OK for mainline and branch?
Cheers,
Mark
Index: java/io/BufferedOutputStream.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/BufferedOutputStream.java,v
retrieving revision 1.7
diff -u -r1.7 BufferedOutputStream.java
--- java/io/BufferedOutputStream.java 15 Jun 2002 18:59:14 -0000 1.7
+++ java/io/BufferedOutputStream.java 13 Feb 2003 20:31:06 -0000
@@ -1,5 +1,5 @@
/* BufferedOutputStream.java -- Buffer output into large blocks before writing
- Copyright (C) 1998, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2000, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -189,11 +189,11 @@
public synchronized void
write(int b) throws IOException
{
- buf[count] = (byte)(b & 0xFF);
-
- ++count;
if (count == buf.length)
flush();
+
+ buf[count] = (byte)(b & 0xFF);
+ ++count;
}
/*************************************************************************/