From 89bfa64e907aff5a683cedd9c84860ee3d10ba4f Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Fri, 19 May 2017 14:49:18 +0300 Subject: [PATCH] Minor: simplify code in RedundantGotoMethodTransformer --- .../RedundantGotoMethodTransformer.kt | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/RedundantGotoMethodTransformer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/RedundantGotoMethodTransformer.kt index 72043f4a3b1..c0013505149 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/RedundantGotoMethodTransformer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/RedundantGotoMethodTransformer.kt @@ -34,18 +34,14 @@ class RedundantGotoMethodTransformer : MethodTransformer() { val currentLabels = hashSetOf() for (insn in insns) { - if (insn.isMeaningful) { - if (insn.opcode == Opcodes.GOTO && (insn as JumpInsnNode).label in currentLabels) { + when { + insn is LabelNode -> + currentLabels.add(insn) + insn.opcode == Opcodes.GOTO && + (insn as JumpInsnNode).label in currentLabels -> insnsToRemove.add(insn) - } - else { + insn.isMeaningful -> currentLabels.clear() - } - continue - } - - if (insn is LabelNode) { - currentLabels.add(insn) } }