Use the ObjectStream size during copyTo
If the stream is a delta decompression stream, getting the size can be expensive. Its cheaper to get it from the stream itself rather than from the object loader. Change-Id: Ia7f0af98681f6d56ea419a48c6fa8eea09274b28 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
parent
1c3f3fdbd2
commit
b474de1da3
|
@ -166,6 +166,7 @@ public void copyTo(OutputStream out) throws MissingObjectException,
|
||||||
if (isLarge()) {
|
if (isLarge()) {
|
||||||
ObjectStream in = openStream();
|
ObjectStream in = openStream();
|
||||||
try {
|
try {
|
||||||
|
final long sz = in.getSize();
|
||||||
byte[] tmp = new byte[1024];
|
byte[] tmp = new byte[1024];
|
||||||
long copied = 0;
|
long copied = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -175,7 +176,7 @@ public void copyTo(OutputStream out) throws MissingObjectException,
|
||||||
out.write(tmp, 0, n);
|
out.write(tmp, 0, n);
|
||||||
copied += n;
|
copied += n;
|
||||||
}
|
}
|
||||||
if (copied != getSize())
|
if (copied != sz)
|
||||||
throw new EOFException();
|
throw new EOFException();
|
||||||
} finally {
|
} finally {
|
||||||
in.close();
|
in.close();
|
||||||
|
|
Loading…
Reference in New Issue