]> source.dussan.org Git - jgit.git/commitdiff
Performance improvement on writing a large index 67/112067/4
authorStephen Lawson <slawson@ptc.com>
Wed, 22 Nov 2017 12:41:05 +0000 (12:41 +0000)
committerMatthias Sohn <matthias.sohn@sap.com>
Fri, 24 Nov 2017 01:07:41 +0000 (20:07 -0500)
The index header consists of a 4-byte version number. The current
supported version numbers are 2 and 3. The code checks if any entries
are extended. If it finds any entries that are extended it picks version
'3', otherwise it chooses version '2'.

DirCache.java
-Changed the 'extended' check to exit early when any entry is considered
'extended' in the index.

(Of course, I maybe missing a bitwise optimization that is made in
the Java bytecode.)

Change-Id: If70db9454befe683319b974ebd3774060be9445d
Signed-off-by: Stephen Lawson <slawson@ptc.com>
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java

index ce52fedcb306937081676f4537d4eb24e42c23df..e00d12073516946402945e374d583c4f3ec4fa2e 100644 (file)
@@ -655,8 +655,12 @@ public class DirCache {
                final DigestOutputStream dos = new DigestOutputStream(os, foot);
 
                boolean extended = false;
-               for (int i = 0; i < entryCnt; i++)
-                       extended |= sortedEntries[i].isExtended();
+               for (int i = 0; i < entryCnt; i++) {
+                       if (sortedEntries[i].isExtended()) {
+                               extended = true;
+                               break;
+                       }
+               }
 
                // Write the header.
                //