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