Building bitmaps: Simplify the logic to sort by chains
Change-Id: I3da98e85107154c159093c138893f54dfa7ef435 Signed-off-by: Terry Parker <tparker@google.com>
This commit is contained in:
parent
f6b9cd38ca
commit
1eee0466ca
|
@ -269,30 +269,23 @@ Collection<BitmapCommit> selectCommits(int expectedCommitCount)
|
||||||
// selected commit to fullBitmap.
|
// selected commit to fullBitmap.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the commits by independent chains in its history,
|
// Sort the commits by independent chains in this branch's
|
||||||
// yielding better compression when building bitmaps.
|
// history, yielding better compression when building bitmaps.
|
||||||
List<List<BitmapCommit>> candidateChain = new ArrayList<
|
List<BitmapCommit> longestAncestorChain = null;
|
||||||
List<BitmapCommit>>();
|
|
||||||
for (List<BitmapCommit> chain : chains) {
|
for (List<BitmapCommit> chain : chains) {
|
||||||
BitmapCommit mostRecentCommit = chain.get(chain.size() - 1);
|
BitmapCommit mostRecentCommit = chain.get(chain.size() - 1);
|
||||||
if (fullBitmap.contains(mostRecentCommit)) {
|
if (fullBitmap.contains(mostRecentCommit)) {
|
||||||
candidateChain.add(chain);
|
if (longestAncestorChain == null
|
||||||
}
|
|| longestAncestorChain.size() < chain.size()) {
|
||||||
}
|
|
||||||
|
|
||||||
List<BitmapCommit> longestAncestorChain;
|
|
||||||
if (candidateChain.isEmpty()) {
|
|
||||||
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 = chain;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (longestAncestorChain == null) {
|
||||||
|
longestAncestorChain = new ArrayList<BitmapCommit>();
|
||||||
|
chains.add(longestAncestorChain);
|
||||||
|
}
|
||||||
longestAncestorChain.add(new BitmapCommit(
|
longestAncestorChain.add(new BitmapCommit(
|
||||||
c, !longestAncestorChain.isEmpty(), flags));
|
c, !longestAncestorChain.isEmpty(), flags));
|
||||||
writeBitmaps.addBitmap(c, fullBitmap, 0);
|
writeBitmaps.addBitmap(c, fullBitmap, 0);
|
||||||
|
|
Loading…
Reference in New Issue