mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
spare some memory in vcs log
This commit is contained in:
@@ -2,10 +2,12 @@ package com.intellij.vcs.log.data;
|
||||
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.vcs.log.Hash;
|
||||
import com.intellij.vcs.log.VcsRef;
|
||||
import gnu.trove.TIntObjectHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -19,7 +21,7 @@ public class RefsModel {
|
||||
|
||||
@NotNull private final Collection<VcsRef> myBranches;
|
||||
@NotNull private final MultiMap<Hash, VcsRef> myRefsToHashes;
|
||||
@NotNull private final MultiMap<Integer, VcsRef> myRefsToIndices;
|
||||
@NotNull private final TIntObjectHashMap<SmartList<VcsRef>> myRefsToIndices;
|
||||
@NotNull private final NotNullFunction<Hash, Integer> myIndexGetter;
|
||||
|
||||
public RefsModel(@NotNull Collection<VcsRef> allRefs, @NotNull NotNullFunction<Hash, Integer> indexGetter) {
|
||||
@@ -36,17 +38,20 @@ public class RefsModel {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private MultiMap<Integer, VcsRef> prepareRefsToIndicesMap(@NotNull Collection<VcsRef> refs) {
|
||||
MultiMap<Integer, VcsRef> map = MultiMap.create();
|
||||
private TIntObjectHashMap<SmartList<VcsRef>> prepareRefsToIndicesMap(@NotNull Collection<VcsRef> refs) {
|
||||
TIntObjectHashMap<SmartList<VcsRef>> map = new TIntObjectHashMap<SmartList<VcsRef>>();
|
||||
for (VcsRef ref : refs) {
|
||||
map.putValue(myIndexGetter.fun(ref.getCommitHash()), ref);
|
||||
int index = myIndexGetter.fun(ref.getCommitHash());
|
||||
SmartList<VcsRef> list = map.get(index);
|
||||
if (list == null) map.put(index, list = new SmartList<VcsRef>());
|
||||
list.add(ref);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static MultiMap<Hash, VcsRef> prepareRefsMap(@NotNull Collection<VcsRef> refs) {
|
||||
MultiMap<Hash, VcsRef> map = MultiMap.create();
|
||||
MultiMap<Hash, VcsRef> map = MultiMap.createSmartList();
|
||||
for (VcsRef ref : refs) {
|
||||
map.putValue(ref.getCommitHash(), ref);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user