From d01d1861305416315923702cafe2b063ac94398e Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Thu, 19 Jun 2014 16:17:41 +0400 Subject: [PATCH] Pseudocode: Fix depth-first pseudocode traversal --- .../jetbrains/jet/lang/cfg/PseudocodeTraverser.kt | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) 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 }