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:
parent
ab3c68c512
commit
f29741d1d8
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue