diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/facade/SimpleGraphInfo.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/facade/SimpleGraphInfo.java index 345c36eb8807..aaefd59e063a 100644 --- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/facade/SimpleGraphInfo.java +++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/facade/SimpleGraphInfo.java @@ -92,12 +92,7 @@ public final class SimpleGraphInfo implements PermanentGraphInfo layoutIndexes[o])); - int[] starts = new int[headNodeIndexes.size()]; - for (int i = 0; i < starts.length; i++) { - starts[i] = layoutIndexes[headNodeIndexes.getInt(i)]; - } - - GraphLayoutImpl newLayout = new GraphLayoutImpl(layoutIndexes, headNodeIndexes, starts); + GraphLayoutImpl newLayout = new GraphLayoutImpl(layoutIndexes, headNodeIndexes); return new SimpleGraphInfo<>(newLinearGraph, newLayout, commitIdMapping, timestampGetter, LinearGraphUtils.convertIdsToNodeIndexes(linearGraph, branchNodeIds)); diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/permanent/GraphLayoutBuilder.kt b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/permanent/GraphLayoutBuilder.kt index 08a7e25afc20..4fd7c2125cae 100644 --- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/permanent/GraphLayoutBuilder.kt +++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/permanent/GraphLayoutBuilder.kt @@ -25,13 +25,11 @@ object GraphLayoutBuilder { val sortedHeads = IntArrayList(allHeads).sortCatching(comparator) val layoutIndex = IntArray(graph.nodesCount()) - val startLayoutIndexForHead = IntArray(sortedHeads.size) var currentLayoutIndex = 1 for (i in sortedHeads.indices) { - startLayoutIndexForHead[i] = currentLayoutIndex currentLayoutIndex = dfs(graph, sortedHeads.getInt(i), currentLayoutIndex, layoutIndex) } - return GraphLayoutImpl(layoutIndex, sortedHeads, startLayoutIndexForHead) + return GraphLayoutImpl(layoutIndex, sortedHeads) } /** diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/permanent/GraphLayoutImpl.kt b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/permanent/GraphLayoutImpl.kt index 8f951eff1f16..ecdc47f10364 100644 --- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/permanent/GraphLayoutImpl.kt +++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/permanent/GraphLayoutImpl.kt @@ -7,9 +7,8 @@ import it.unimi.dsi.fastutil.ints.IntList import java.util.* import kotlin.math.max -class GraphLayoutImpl(layoutIndex: IntArray, - private val headNodeIndex: IntList, - private val startLayoutIndexForHead: IntArray) : GraphLayout { +class GraphLayoutImpl(layoutIndex: IntArray, private val headNodeIndex: IntList) : GraphLayout { + private val startLayoutIndexForHead = getLayoutIndexesForHeads(layoutIndex, headNodeIndex) private val layoutIndex = CompressedIntList.newInstance(layoutIndex) override fun getLayoutIndex(nodeIndex: Int) = layoutIndex[nodeIndex] @@ -25,3 +24,11 @@ class GraphLayoutImpl(layoutIndex: IntArray, return if (i < 0) max(0, (-i - 2)) else i } } + +private fun getLayoutIndexesForHeads(layoutIndexes: IntArray, headNodeIndexes: IntList): IntArray { + val result = IntArray(headNodeIndexes.size) + for (i in result.indices) { + result[i] = layoutIndexes[headNodeIndexes.getInt(i)] + } + return result +}