Re: [JGIT PATCH 2/5] Add copy(InputStream) to TemporaryBuffer
- From
Shawn O. Pearce <spearce@spearce.org>
- Date
- Dec 11, 2008, 15:52 UTC
- Message-ID
- <20081211155218.GF32487@spearce.org>
- In-Reply-To
- <200812111640.34435.robin.rosenberg@dewire.com>
Robin Rosenberg <robin.rosenberg@dewire.com> wrote:
Show 9 quoted lines
> torsdag 11 december 2008 05:58:39 skrev Shawn O. Pearce:
> > In some places we may find it ourselves with an InputStream we
> > need to copy into a TemporaryBuffer, so we can flatten out the
> > entire stream to a single byte[]. Putting the copy loop here
> > is more useful then duplicating it in application level code.
> > + public void copy(final InputStream in) throws IOException {
> > + final byte[] b = new byte[2048];
>
> Why not 8192 here too?Blargh, you're right. Actually what I should do is look to see if blocks != null, in which case I should alloc a block and read directly into it. That would avoid one copy of the data.
-- Shawn.