Minor. Rewrite part in CoroutineTransformer with 'run'

It helps to avoid unnecessary val customCoroutineStartMarker
in the scope of performTransformations
This commit is contained in:
Denis Zharkov
2017-04-25 15:59:51 +03:00
parent c3a032ea0b
commit 035fcc2424
@@ -54,12 +54,15 @@ class CoroutineTransformerMethodVisitor(
private val exceptionIndex = dataIndex + 1
override fun performTransformations(methodNode: MethodNode) {
val customCoroutineStartMarker = methodNode.instructions.toArray().filterIsInstance<MethodInsnNode>().firstOrNull {
it.owner == COROUTINE_MARKER_OWNER && it.name == ACTUAL_COROUTINE_START_MARKER_NAME
}
val customCoroutineStart = run {
val customCoroutineStartMarker = methodNode.instructions.toArray().filterIsInstance<MethodInsnNode>().firstOrNull {
it.owner == COROUTINE_MARKER_OWNER && it.name == ACTUAL_COROUTINE_START_MARKER_NAME
}
val customCoroutineStart = customCoroutineStartMarker?.next
customCoroutineStartMarker?.let(methodNode.instructions::remove)
customCoroutineStartMarker?.next?.also {
methodNode.instructions.remove(customCoroutineStartMarker)
}
}
val suspensionPoints = collectSuspensionPoints(methodNode)