db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dyre.Tjeldv...@Sun.COM
Subject Re: ArrayInputStream and performance
Date Fri, 24 Nov 2006 18:08:14 GMT
Knut Anders Hatlen <Knut.Hatlen@Sun.COM> writes:

> I can't answer your question, but I will add that I find much of the
> code that uses ArrayInputStream very confusing. ArrayInputStream is
> supposed to wrap a byte array to provide encapsulation and easy access
> to the data through the InputStream interface. However, many (most?)
> of the callers inline the accesses to the data (presumably for
> performance reasons), so we end up with lots of methods looking like
> this:
>   public X readSomething(ArrayInputStream ais, byte[] data, int offset...) {
>     // lots of direct manipulation of the byte array
>     // ...
>     // ...
>     // ...
>     // finally, make sure that the state of the stream is brought to a
>     // consistent state:
>     ais.setPosition(offset + numberOfManipulatedBytes);
>   }
> Both the byte array and the offset are part of the ArrayInputStream
> class, so having all three of them in the parameter list feels a bit
> ugly. And if we need to manipulate the internal state directly that
> often, perhaps an InputStream is not the best data structure in the
> first place?

I tend to agree. I just finished running derbyall with the checks
replaced by ASSERTs and I saw no failures. So unless I hear strong
objections I'll create a Jira for this change.


View raw message