diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeTraverser.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeTraverser.kt index 1fb527543c3..d2be8fb0102 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeTraverser.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeTraverser.kt @@ -49,10 +49,8 @@ fun Pseudocode.traverse( if (instruction is LocalFunctionDeclarationInstruction) { instruction.body.traverse(traversalOrder, edgesMap, analyzeInstruction) } - val edges = edgesMap[instruction] - if (edges != null) { - analyzeInstruction(instruction, edges.incoming, edges.outgoing) - } + val edges = edgesMap[instruction] ?: continue + analyzeInstruction(instruction, edges.incoming, edges.outgoing) } } @@ -63,7 +61,8 @@ fun > Pseudocode.collectData( initialInfo: I ): Map> { val edgesMap = LinkedHashMap>() - edgesMap.put(getStartInstruction(traversalOrder), Edges(initialInfo, initialInfo)) + val startInstruction = getStartInstruction(traversalOrder) + edgesMap[startInstruction] = Edges(initialInfo, initialInfo) val changed = mutableMapOf() do { @@ -125,15 +124,10 @@ private fun > Pseudocode.collectDataFromSubgraph( val incomingEdgesData = HashSet() for (previousInstruction in previousInstructions) { - val previousData = edgesMap[previousInstruction] - if (previousData != null) { - incomingEdgesData.add( - updateEdge( - previousInstruction, instruction, previousData.outgoing - ) - ) - } + val previousData = edgesMap[previousInstruction] ?: continue + incomingEdgesData.add(updateEdge(previousInstruction, instruction, previousData.outgoing)) } + val mergedData = mergeEdges(instruction, incomingEdgesData) updateEdgeDataForInstruction(instruction, previousDataValue, mergedData, edgesMap, changed) } @@ -163,7 +157,7 @@ private fun > updateEdgeDataForInstruction( ) { if (previousValue != newValue && newValue != null) { changed[instruction] = true - edgesMap.put(instruction, newValue) + edgesMap[instruction] = newValue } else { changed[instruction] = false }