diff options
author | Terry Parker <tparker@google.com> | 2015-10-29 11:02:01 -0700 |
---|---|---|
committer | Terry Parker <tparker@google.com> | 2015-10-29 11:25:24 -0700 |
commit | 1eee0466ca9ac8dd04d7896f8e4aae3d7d31926f (patch) | |
tree | 1c012c05c00b459ea9bfb2c43f330f0253fa4934 /org.eclipse.jgit | |
parent | f6b9cd38cae29db4203d30b82dedeb818cdbe829 (diff) | |
download | jgit-1eee0466ca9ac8dd04d7896f8e4aae3d7d31926f.tar.gz jgit-1eee0466ca9ac8dd04d7896f8e4aae3d7d31926f.zip |
Building bitmaps: Simplify the logic to sort by chains
Change-Id: I3da98e85107154c159093c138893f54dfa7ef435
Signed-off-by: Terry Parker <tparker@google.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java index e250289bd7..a58caa924b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java @@ -269,29 +269,22 @@ class PackWriterBitmapPreparer { // selected commit to fullBitmap. } - // Sort the commits by independent chains in its history, - // yielding better compression when building bitmaps. - List<List<BitmapCommit>> candidateChain = new ArrayList< - List<BitmapCommit>>(); + // Sort the commits by independent chains in this branch's + // history, yielding better compression when building bitmaps. + List<BitmapCommit> longestAncestorChain = null; for (List<BitmapCommit> chain : chains) { BitmapCommit mostRecentCommit = chain.get(chain.size() - 1); if (fullBitmap.contains(mostRecentCommit)) { - candidateChain.add(chain); + if (longestAncestorChain == null + || longestAncestorChain.size() < chain.size()) { + longestAncestorChain = chain; + } } } - List<BitmapCommit> longestAncestorChain; - if (candidateChain.isEmpty()) { + if (longestAncestorChain == null) { longestAncestorChain = new ArrayList<BitmapCommit>(); chains.add(longestAncestorChain); - } else { - longestAncestorChain = candidateChain.get(0); - // Append to longest - for (List<BitmapCommit> chain : candidateChain) { - if (chain.size() > longestAncestorChain.size()) { - longestAncestorChain = chain; - } - } } longestAncestorChain.add(new BitmapCommit( c, !longestAncestorChain.isEmpty(), flags)); |