From b474de1da381174b0f769c4e1541cd39e5016572 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 24 Aug 2010 12:56:47 -0700 Subject: [PATCH] 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 --- org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectLoader.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectLoader.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectLoader.java index e19bfc4fba..e8a125d575 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectLoader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectLoader.java @@ -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(); -- 2.39.5