From c7ef2644d83e1d8e84decb0631a6549d394180fc Mon Sep 17 00:00:00 2001 From: Lucaskyy Date: Thu, 24 Mar 2022 23:37:28 +0100 Subject: [PATCH] perf: check type instead of class this is way better, thank you oSumAtrIX! --- .../app/revanced/patcher/resolver/MethodResolver.kt | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/app/revanced/patcher/resolver/MethodResolver.kt b/src/main/kotlin/app/revanced/patcher/resolver/MethodResolver.kt index ae0b8683..ca0a41aa 100644 --- a/src/main/kotlin/app/revanced/patcher/resolver/MethodResolver.kt +++ b/src/main/kotlin/app/revanced/patcher/resolver/MethodResolver.kt @@ -129,13 +129,7 @@ private fun InsnList.scanFor(pattern: IntArray): ScanResult { var occurrence = 0 while (i + occurrence < this.size()) { val n = this[i + occurrence] - if ( - !n.anyOf( - LabelNode::class.java, - LineNumberNode::class.java - ) && - n.opcode != pattern[occurrence] - ) break + if (!n.shouldSkip() && n.opcode != pattern[occurrence]) break if (++occurrence >= pattern.size) { val current = i + occurrence return ScanResult(true, current - pattern.size, current) @@ -158,5 +152,5 @@ private fun Array.convertObjects(): Array { return this.map { it.convertObject() }.toTypedArray() } -private fun AbstractInsnNode.anyOf(vararg types: Class<*>): Boolean = - types.any { this@anyOf.javaClass == it } \ No newline at end of file +private fun AbstractInsnNode.shouldSkip() = + type == AbstractInsnNode.LABEL || type == AbstractInsnNode.LINE