Browse Source

Speedup CleanFilter by transferring data in chunks of 8k

Transferring data byte per byte is slow, running add with CleanFilter on
a 2.9MB file takes 20 seconds. Using a buffer of 8k shrinks this time to
70ms.

Change-Id: I3bc2d8c11fe6cfaffcc99dc2a00643e01ac4e9cc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-4.6
Matthias Sohn 8 years ago
parent
commit
6dea5ec823
  1. 11
      org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java

11
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java

@ -141,11 +141,12 @@ public class CleanFilter extends FilterCommand {
public int run() throws IOException { public int run() throws IOException {
try { try {
int b = in.read(); byte[] buf = new byte[8192];
if (b != -1) { int length = in.read(buf);
dOut.write(b); if (length != -1) {
size++; dOut.write(buf, 0, length);
return 1; size += length;
return length;
} else { } else {
dOut.close(); dOut.close();
tmpOut.close(); tmpOut.close();

Loading…
Cancel
Save