summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2013-04-10 09:33:56 -0700
committerShawn Pearce <spearce@spearce.org>2013-04-10 12:58:51 -0700
commit2be6927d8e707458e7efdfa4b585a3dd627c7346 (patch)
treef2fed2859bca8bd408085d9844339c46f4b71c51
parenteb17495ca4ce95c63bacf81af16ab19ff042b65c (diff)
downloadjgit-2be6927d8e707458e7efdfa4b585a3dd627c7346.tar.gz
jgit-2be6927d8e707458e7efdfa4b585a3dd627c7346.zip
Always allocate the PackOutputStream copyBuffer
The getCopyBuffer() is almost always used during output. All known implementations of ObjectReuseAsIs rely on the buffer to be present, and the only sane way to get good performance from PackWriter is to reuse objects during packing. Avoid a branch and test when obtaining this buffer by making sure it is always populated. Change-Id: I200baa0bde5dcdd11bab7787291ad64535c9f7fb
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackOutputStream.java6
1 files changed, 2 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackOutputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackOutputStream.java
index ea6781495d..fcf054c9cc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackOutputStream.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackOutputStream.java
@@ -67,9 +67,9 @@ public final class PackOutputStream extends OutputStream {
private long count;
- private byte[] headerBuffer = new byte[32];
+ private final byte[] headerBuffer = new byte[32];
- private byte[] copyBuffer;
+ private final byte[] copyBuffer = new byte[16 << 10];
private long checkCancelAt;
@@ -216,8 +216,6 @@ public final class PackOutputStream extends OutputStream {
/** @return a temporary buffer writers can use to copy data with. */
public byte[] getCopyBuffer() {
- if (copyBuffer == null)
- copyBuffer = new byte[16 * 1024];
return copyBuffer;
}