Browse Source

Use 8192 as default buffer size in ObjectLoader copyTo

As ObjectStreams are supposed to be buffered, most implementors will
be wrapping their underlying stream inside of a BufferedInputStream
in order to satisfy this requirement.  Because developers are by
nature lazy, they will use the default buffer size rather than
specify their own.

The OpenJDk JRE implementations use 8192 as the default buffer
size, and when the higher level reader uses the same buffer size
the buffers "stack" nicely by avoiding a copy to the internal
buffer array.  As OpenJDK is a popular virtual machine, we should
try to benefit from this nice stacking property during copyTo().

Change-Id: I69d53f273b870b841ced2be2e9debdfd987d98f4
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
tags/v0.9.1
Shawn O. Pearce 13 years ago
parent
commit
693f454e71
1 changed files with 1 additions and 1 deletions
  1. 1
    1
      org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectLoader.java

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectLoader.java View File

@@ -256,7 +256,7 @@ public abstract class ObjectLoader {
ObjectStream in = openStream();
try {
final long sz = in.getSize();
byte[] tmp = new byte[1024];
byte[] tmp = new byte[8192];
long copied = 0;
while (copied < sz) {
int n = in.read(tmp);

Loading…
Cancel
Save