]> source.dussan.org Git - jgit.git/commitdiff
Use the ObjectStream size during copyTo 96/1396/2
authorShawn O. Pearce <spearce@spearce.org>
Tue, 24 Aug 2010 19:56:47 +0000 (12:56 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Wed, 25 Aug 2010 00:37:07 +0000 (17:37 -0700)
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>
org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectLoader.java

index e19bfc4fba8b48395552a01aed7a3208ec29cd9f..e8a125d5753be6f904a4314b7884e244ae6ff7c3 100644 (file)
@@ -166,6 +166,7 @@ public abstract class ObjectLoader {
                if (isLarge()) {
                        ObjectStream in = openStream();
                        try {
+                               final long sz = in.getSize();
                                byte[] tmp = new byte[1024];
                                long copied = 0;
                                for (;;) {
@@ -175,7 +176,7 @@ public abstract class ObjectLoader {
                                        out.write(tmp, 0, n);
                                        copied += n;
                                }
-                               if (copied != getSize())
+                               if (copied != sz)
                                        throw new EOFException();
                        } finally {
                                in.close();