Parcourir la 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 il y a 13 ans
Parent
révision
693f454e71
1 fichiers modifiés avec 1 ajouts et 1 suppressions
  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 Voir le fichier

@@ -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);

Chargement…
Annuler
Enregistrer