[log] Show branches in BranchesPanel instead of all refs.

This improves performance of sorting references when there are
many tags in the repository.

Better grouping capabilities will be provided later.
This commit is contained in:
Kirill Likhodedov
2013-10-21 17:40:06 +04:00
parent 7d52e6d19b
commit 658130843e
2 changed files with 15 additions and 1 deletions
@@ -1,5 +1,7 @@
package com.intellij.vcs.log.data;
import com.intellij.openapi.util.Condition;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsRef;
import org.jetbrains.annotations.NotNull;
@@ -12,11 +14,19 @@ import java.util.*;
public class RefsModel {
@NotNull private final Collection<VcsRef> myRefs;
@NotNull private final Collection<VcsRef> myBranches;
@NotNull private final Set<Hash> myRefHashes;
public RefsModel(@NotNull Collection<VcsRef> allRefs) {
myRefs = allRefs;
myBranches = ContainerUtil.filter(myRefs, new Condition<VcsRef>() {
@Override
public boolean value(VcsRef ref) {
return ref.getType().isBranch();
}
});
myRefHashes = new HashSet<Hash>();
for (VcsRef ref : myRefs) {
myRefHashes.add(ref.getCommitHash());
@@ -50,4 +60,8 @@ public class RefsModel {
return Collections.unmodifiableCollection(myRefs);
}
@NotNull
public Collection<VcsRef> getBranches() {
return myBranches;
}
}
@@ -82,7 +82,7 @@ public class BranchesPanel extends JPanel {
@NotNull
private List<VcsRef> getRefsToDisplayOnPanel() {
Collection<VcsRef> allRefs = myDataHolder.getDataPack().getRefsModel().getAllRefs();
Collection<VcsRef> allRefs = myDataHolder.getDataPack().getRefsModel().getBranches();
List<VcsRef> refsToShow = new ArrayList<VcsRef>();
for (Map.Entry<VirtualFile, Collection<VcsRef>> entry : groupByRoot(allRefs).entrySet()) {