]> source.dussan.org Git - jgit.git/commitdiff
Speedup CleanFilter by transferring data in chunks of 8k 79/83779/3
authorMatthias Sohn <matthias.sohn@sap.com>
Mon, 24 Oct 2016 11:26:58 +0000 (13:26 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Wed, 26 Oct 2016 20:54:48 +0000 (22:54 +0200)
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>
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java

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