Browse Source

Building bitmaps: Simplify the logic to sort by chains

Change-Id: I3da98e85107154c159093c138893f54dfa7ef435
Signed-off-by: Terry Parker <tparker@google.com>
stable-4.2
Terry Parker 9 years ago
parent
commit
1eee0466ca
  1. 23
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java

23
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));

Loading…
Cancel
Save