diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/IndexDataGetter.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/IndexDataGetter.java index e67922709be5..745051eec489 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/IndexDataGetter.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/IndexDataGetter.java @@ -21,11 +21,13 @@ import com.intellij.openapi.util.UnorderedPair; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.containers.Interner; import com.intellij.util.containers.SmartHashSet; import com.intellij.util.indexing.StorageException; import com.intellij.vcs.log.impl.FatalErrorHandler; import com.intellij.vcsUtil.VcsUtil; import gnu.trove.TIntObjectHashMap; +import gnu.trove.TIntObjectIterator; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -83,6 +85,7 @@ public class IndexDataGetter { if (myRoots.contains(root)) { try { myIndexStorage.paths.iterateCommits(Collections.singleton(path), (paths, commit) -> result.add(commit, paths)); + result.pack(); } catch (IOException | StorageException e) { myFatalErrorsConsumer.consume(this, e); @@ -93,6 +96,7 @@ public class IndexDataGetter { } public static class FileNamesData { + @NotNull private final Interner> myPathsInterner = new Interner<>(); @NotNull private final TIntObjectHashMap> myCommitsToPaths; @NotNull private final TIntObjectHashMap>> myCommitsToRenames; @@ -117,13 +121,13 @@ public class IndexDataGetter { private void addRename(int commit, @NotNull Couple path) { Set> paths = myCommitsToRenames.get(commit); if (paths == null) { - paths = new SmartHashSet<>(); + paths = ContainerUtil.newHashSet(); myCommitsToRenames.put(commit, paths); } paths.add(new UnorderedPair<>(path.first, path.second)); } - public void add(int commit, @NotNull Couple paths) { + private void add(int commit, @NotNull Couple paths) { if (paths.second == null) { addPath(commit, paths.first); } @@ -164,7 +168,7 @@ public class IndexDataGetter { public void retain(int commit, @NotNull FilePath path, @NotNull FilePath previousPath) { if (path.equals(previousPath)) { - myCommitsToPaths.put(commit, ContainerUtil.set(path)); + myCommitsToPaths.put(commit, myPathsInterner.intern(ContainerUtil.set(path))); myCommitsToRenames.remove(commit); } else { @@ -190,5 +194,13 @@ public class IndexDataGetter { return result; } + + void pack() { + TIntObjectIterator> iterator = myCommitsToPaths.iterator(); + while (iterator.hasNext()) { + iterator.advance(); + iterator.setValue(myPathsInterner.intern(iterator.value())); + } + } } }