Browse Source

Avoid repeated sort of tipCommitBitmaps

Change-Id: I0feb2003f58776d50fab2d31d46ac98ae863bea8
stable-4.2
Jonathan Nieder 9 years ago
parent
commit
65e04a2a92
  1. 11
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java

11
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java

@ -89,10 +89,10 @@ class PackWriterBitmapPreparer {
private static final int DAY_IN_SECONDS = 24 * 60 * 60; private static final int DAY_IN_SECONDS = 24 * 60 * 60;
private static final Comparator<BitmapBuilderEntry> ORDER_BY_DESCENDING_CARDINALITY = new Comparator<BitmapBuilderEntry>() { private static final Comparator<BitmapBuilderEntry> ORDER_BY_CARDINALITY = new Comparator<BitmapBuilderEntry>() {
public int compare(BitmapBuilderEntry a, BitmapBuilderEntry b) { public int compare(BitmapBuilderEntry a, BitmapBuilderEntry b) {
return Integer.signum(b.getBuilder().cardinality() return Integer.signum(a.getBuilder().cardinality()
- a.getBuilder().cardinality()); - b.getBuilder().cardinality());
} }
}; };
@ -449,8 +449,9 @@ class PackWriterBitmapPreparer {
List<BitmapBuilderEntry> orderedTipCommitBitmaps = new ArrayList<>( List<BitmapBuilderEntry> orderedTipCommitBitmaps = new ArrayList<>(
tipCommitBitmaps.size()); tipCommitBitmaps.size());
while (!tipCommitBitmaps.isEmpty()) { while (!tipCommitBitmaps.isEmpty()) {
Collections.sort(tipCommitBitmaps, ORDER_BY_DESCENDING_CARDINALITY); BitmapBuilderEntry largest =
BitmapBuilderEntry largest = tipCommitBitmaps.remove(0); Collections.max(tipCommitBitmaps, ORDER_BY_CARDINALITY);
tipCommitBitmaps.remove(largest);
orderedTipCommitBitmaps.add(largest); orderedTipCommitBitmaps.add(largest);
// Update the remaining paths, by removing the objects from // Update the remaining paths, by removing the objects from

Loading…
Cancel
Save