From 1eee0466ca9ac8dd04d7896f8e4aae3d7d31926f Mon Sep 17 00:00:00 2001 From: Terry Parker Date: Thu, 29 Oct 2015 11:02:01 -0700 Subject: [PATCH] Building bitmaps: Simplify the logic to sort by chains Change-Id: I3da98e85107154c159093c138893f54dfa7ef435 Signed-off-by: Terry Parker --- .../pack/PackWriterBitmapPreparer.java | 23 +++++++------------ 1 file 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> candidateChain = new ArrayList< - List>(); + // Sort the commits by independent chains in this branch's + // history, yielding better compression when building bitmaps. + List longestAncestorChain = null; for (List 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 longestAncestorChain; - if (candidateChain.isEmpty()) { + if (longestAncestorChain == null) { longestAncestorChain = new ArrayList(); chains.add(longestAncestorChain); - } else { - longestAncestorChain = candidateChain.get(0); - // Append to longest - for (List chain : candidateChain) { - if (chain.size() > longestAncestorChain.size()) { - longestAncestorChain = chain; - } - } } longestAncestorChain.add(new BitmapCommit( c, !longestAncestorChain.isEmpty(), flags)); -- 2.39.5