Skip to content

Commit

Permalink
Optimize TransformationUtils.isCoroutineStateMachineClass implement…
Browse files Browse the repository at this point in the history
…ation (#294)
  • Loading branch information
ndkoval authored Mar 25, 2024
1 parent d51247c commit ae3c54c
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.objectweb.asm.*
import org.objectweb.asm.Type.*
import org.objectweb.asm.commons.*
import java.io.*
import java.util.concurrent.*
import kotlin.reflect.*
import kotlin.reflect.jvm.*

Expand Down Expand Up @@ -134,8 +135,13 @@ internal inline fun GeneratorAdapter.invokeInIgnoredSection(
)
}

internal fun isCoroutineStateMachineClass(internalClassName: String) =
getSuperclassName(internalClassName) == "kotlin/coroutines/jvm/internal/ContinuationImpl"
private val isCoroutineStateMachineClassMap = ConcurrentHashMap<String, Boolean>()
internal fun isCoroutineStateMachineClass(internalClassName: String): Boolean {
if (internalClassName.startsWith("java/")) return false
return isCoroutineStateMachineClassMap.computeIfAbsent(internalClassName) {
getSuperclassName(internalClassName) == "kotlin/coroutines/jvm/internal/ContinuationImpl"
}
}

private fun getSuperclassName(internalClassName: String): String? {
class SuperclassClassVisitor : ClassVisitor(ASM_API) {
Expand Down

0 comments on commit ae3c54c

Please sign in to comment.