classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Merging BufferedInputStream with libgcj


From: Mark Wielaard
Subject: Merging BufferedInputStream with libgcj
Date: Sun, 7 Oct 2001 00:28:21 +0200
User-agent: Mutt/1.3.22i

Hi,

Today I looked at BufferedInputStream from Classpath and libgcj.
A lot of code was almost the same except for the support for mark()/reset().
The libgcj version just uses the normal buffer array to store the bytes
that had to be remembered for the mark(). When the end of the buffer is
reached a new buffer is created which can hold all extra bytes needed for
the mark(). The Classpath version uses an extra byte buffer when more
bytes have to be remembered then can fit into the normal buffer. But it
uses 4 extra fields to do the bookkeeping required and has a lot of extra
code to get this right.

I decided to take most of the code of the libgcj version and added the
javadoc from Classpath in the merged version. This does mean that when a
large marklimit is given the array buffer will stay extra big even after
the mark expires.

If people think this is a problem then we could add one private field to
remember the original size of the buffer in the constructor and reset the
buffer when the mark is expired in the refill() method. I think that is
not necessary because my feeling is that normally one does not set a mark
much larger then the buffer size given to BufferedInputStream and when
someone does set such a large mark then it is likely that the same large
limit is used again later. But I can only rely on my own experience so
please correct me if this is a silly assumption.

Cheers,

Mark
-- 
Stuff to read:
    <http://www.toad.com/gnu/whatswrong.html>
  What's Wrong with Copy Protection, by John Gilmore



reply via email to

[Prev in Thread] Current Thread [Next in Thread]