diff options
author | Jonathan Nieder <jrn@google.com> | 2015-11-07 12:01:41 -0800 |
---|---|---|
committer | Jonathan Nieder <jrn@google.com> | 2015-11-07 15:36:55 -0800 |
commit | 65e04a2a925755cdcf3ed48d3dcac763d2b45ec3 (patch) | |
tree | c6ca2e08c4e8621ffa45c67e43102cb5225d1a97 | |
parent | 6d19f5dc8f54106b16ad42fc8e69d7c49b681d73 (diff) | |
download | jgit-65e04a2a925755cdcf3ed48d3dcac763d2b45ec3.tar.gz jgit-65e04a2a925755cdcf3ed48d3dcac763d2b45ec3.zip |
Avoid repeated sort of tipCommitBitmaps
Change-Id: I0feb2003f58776d50fab2d31d46ac98ae863bea8
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java | 11 |
1 files changed, 6 insertions, 5 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 e378b4e82d..86669f6b39 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 @@ -89,10 +89,10 @@ class PackWriterBitmapPreparer { 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) { - return Integer.signum(b.getBuilder().cardinality() - - a.getBuilder().cardinality()); + return Integer.signum(a.getBuilder().cardinality() + - b.getBuilder().cardinality()); } }; @@ -449,8 +449,9 @@ class PackWriterBitmapPreparer { List<BitmapBuilderEntry> orderedTipCommitBitmaps = new ArrayList<>( tipCommitBitmaps.size()); while (!tipCommitBitmaps.isEmpty()) { - Collections.sort(tipCommitBitmaps, ORDER_BY_DESCENDING_CARDINALITY); - BitmapBuilderEntry largest = tipCommitBitmaps.remove(0); + BitmapBuilderEntry largest = + Collections.max(tipCommitBitmaps, ORDER_BY_CARDINALITY); + tipCommitBitmaps.remove(largest); orderedTipCommitBitmaps.add(largest); // Update the remaining paths, by removing the objects from |