diff options
author | Stephen Lawson <slawson@ptc.com> | 2017-11-22 12:41:05 +0000 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2017-11-23 20:07:41 -0500 |
commit | e3f19a5298acb67848966f6ba192f3a88abdce72 (patch) | |
tree | 9480464321830c0b32d5b597808b4c8ee27733dc /org.eclipse.jgit/src/org/eclipse/jgit | |
parent | ebee164043035a651b7f3f4113f17ac9f73bf22c (diff) | |
download | jgit-e3f19a5298acb67848966f6ba192f3a88abdce72.tar.gz jgit-e3f19a5298acb67848966f6ba192f3a88abdce72.zip |
Performance improvement on writing a large index
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>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java index ce52fedcb3..e00d120735 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java @@ -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. // |