[vcs-log] do not keep full details in DetailsPanel

This commit is contained in:
Julia Beliaeva
2018-01-21 19:30:20 +03:00
parent 1c2a61ba32
commit 66b3d4fa5d
2 changed files with 30 additions and 9 deletions
@@ -48,6 +48,8 @@ import com.intellij.vcs.log.ui.VcsLogColorManager;
import com.intellij.vcs.log.ui.frame.CommitPresentationUtil.CommitPresentation;
import com.intellij.vcs.log.ui.table.CommitSelectionListener;
import com.intellij.vcs.log.ui.table.VcsLogGraphTable;
import com.intellij.vcs.log.util.TroveUtil;
import gnu.trove.TIntHashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -75,7 +77,7 @@ public class DetailsPanel extends JPanel implements EditorColorsListener, Dispos
@NotNull private final VcsLogColorManager myColorManager;
@NotNull private List<Integer> mySelection = ContainerUtil.emptyList();
@NotNull private Set<VcsFullCommitDetails> myCommitDetails = Collections.emptySet();
@NotNull private TIntHashSet myCommitIds = new TIntHashSet();
@Nullable private ProgressIndicator myResolveIndicator = null;
public DetailsPanel(@NotNull VcsLogData logData,
@@ -254,11 +256,11 @@ public class DetailsPanel extends JPanel implements EditorColorsListener, Dispos
unResolvedHashes));
setPresentations(ids, presentations);
Set<VcsFullCommitDetails> newCommitDetails = ContainerUtil.newHashSet(detailsList);
if (!ContainerUtil.intersects(myCommitDetails, newCommitDetails)) {
TIntHashSet newCommitDetails = TroveUtil.map2IntSet(detailsList, c -> myLogData.getStorage().getCommitIndex(c.getId(), c.getRoot()));
if (!TroveUtil.intersects(myCommitIds, newCommitDetails)) {
myScrollPane.getVerticalScrollBar().setValue(0);
}
myCommitDetails = newCommitDetails;
myCommitIds = newCommitDetails;
List<Integer> currentSelection = mySelection;
resolveHashes(ids, presentations, unResolvedHashes, o -> currentSelection != mySelection);
@@ -316,7 +318,7 @@ public class DetailsPanel extends JPanel implements EditorColorsListener, Dispos
myEmptyText.setText(text);
myMainContentPanel.removeAll();
mySelection = ContainerUtil.emptyList();
myCommitDetails = Collections.emptySet();
myCommitIds = new TIntHashSet();
}
}
@@ -23,11 +23,9 @@ import gnu.trove.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.function.IntFunction;
import java.util.function.ToIntFunction;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
@@ -74,6 +72,18 @@ public class TroveUtil {
return createJavaSet(result);
}
public static boolean intersects(@NotNull TIntHashSet set1, @NotNull TIntHashSet set2) {
if (set1.size() <= set2.size()) {
return !set1.forEach(value -> {
if (set2.contains(value)) {
return false;
}
return true;
});
}
return intersects(set2, set1);
}
@Nullable
private static TIntHashSet intersect(@Nullable TIntHashSet set1, @Nullable TIntHashSet set2) {
if (set1 == null) return set2;
@@ -128,6 +138,15 @@ public class TroveUtil {
return stream(set).mapToObj(function).collect(Collectors.toList());
}
@NotNull
public static <T> TIntHashSet map2IntSet(@NotNull Collection<T> set, @NotNull ToIntFunction<T> function) {
TIntHashSet result = new TIntHashSet();
for (T t : set) {
result.add(function.applyAsInt(t));
}
return result;
}
public static void processBatches(@NotNull IntStream stream,
int batchSize,
@NotNull ThrowableConsumer<TIntHashSet, VcsException> consumer)