amend commit: Support large delta packed objects as streams

Rename the ByteWindow's inflate() method to setInput.  We have
completely refactored the purpose of this method to be feeding part
(or all) of the window as input to the Inflater, and the actual
inflate activity happens in the caller.

Change-Id: Ie93a5bae0e9e637b5e822d56993ce6b562c6ad15
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
Shawn O. Pearce 2010-07-06 19:38:39 -07:00
parent ab3c68c512
commit f29741d1d8
4 changed files with 7 additions and 7 deletions

View File

@ -70,7 +70,7 @@ protected int copy(final int p, final byte[] b, final int o, int n) {
}
@Override
protected int inflate(final int pos, final Inflater inf)
protected int setInput(final int pos, final Inflater inf)
throws DataFormatException {
int n = array.length - pos;
inf.setInput(array, pos, n);

View File

@ -72,7 +72,7 @@ protected int copy(final int p, final byte[] b, final int o, int n) {
}
@Override
protected int inflate(final int pos, final Inflater inf)
protected int setInput(final int pos, final Inflater inf)
throws DataFormatException {
final ByteBuffer s = buffer.slice();
s.position(pos);

View File

@ -117,10 +117,10 @@ final int copy(long pos, byte[] dstbuf, int dstoff, int cnt) {
*/
protected abstract int copy(int pos, byte[] dstbuf, int dstoff, int cnt);
final int inflate(long pos, Inflater inf) throws DataFormatException {
return inflate((int) (pos - start), inf);
final int setInput(long pos, Inflater inf) throws DataFormatException {
return setInput((int) (pos - start), inf);
}
protected abstract int inflate(int pos, Inflater inf)
protected abstract int setInput(int pos, Inflater inf)
throws DataFormatException;
}

View File

@ -171,13 +171,13 @@ int inflate(final PackFile pack, long position, final byte[] dstbuf,
int dstoff) throws IOException, DataFormatException {
prepareInflater();
pin(pack, position);
position += window.inflate(position, inf);
position += window.setInput(position, inf);
do {
int n = inf.inflate(dstbuf, dstoff, dstbuf.length - dstoff);
if (n == 0) {
if (inf.needsInput()) {
pin(pack, position);
position += window.inflate(position, inf);
position += window.setInput(position, inf);
} else if (inf.finished())
return dstoff;
else