diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/PseudocodeTraverser.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/PseudocodeTraverser.kt index 892aea97202..d6a40033efa 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/PseudocodeTraverser.kt +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/PseudocodeTraverser.kt @@ -181,18 +181,10 @@ fun traverseFollowingInstructions( while (!stack.isEmpty()) { val instruction = stack.pop() - visited.add(instruction) + if (!visited.add(instruction)) continue + if (handler != null && !handler(instruction)) return false - val followingInstructions = instruction.getNextInstructions(order) - - for (followingInstruction in followingInstructions) { - if (!visited.contains(followingInstruction)) { - if (handler != null && !handler(instruction)) { - return false - } - stack.push(followingInstruction) - } - } + instruction.getNextInstructions(order).forEach { stack.push(it) } } return true }