瀏覽代碼

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 年之前
父節點
當前提交
693f454e71
共有 1 個檔案被更改,包括 1 行新增1 行删除
  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 查看文件

@@ -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…
取消
儲存