Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Nov 9, 2024
1 parent 708e91e commit 2ecec37
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions src/main/kotlin/app/revanced/patcher/patch/BytecodePatchContext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,10 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi
* @return A proxy for the first class that matches the predicate.
*/
fun classBy(predicate: (ClassDef) -> Boolean): ClassProxy? {
synchronized(classes.proxyPool) {
val proxy = classes.proxyPool.find { predicate(it.immutableClass) }
if (proxy != null) return proxy;
}

val classDef: ClassDef?
synchronized(classes) {
classDef = classes.find(predicate)
}
val proxy = synchronized(classes.proxyPool) { classes.proxyPool.find { predicate(it.immutableClass) } }
if (proxy != null) return proxy

val classDef = synchronized(classes) { classes.find(predicate) }
if (classDef != null) {
return proxy(classDef)
}
Expand All @@ -123,13 +117,9 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi
*
* @return A proxy for the class.
*/
fun proxy(classDef: ClassDef) : ClassProxy {
val proxyPool = classes.proxyPool
synchronized(proxyPool) {
return proxyPool.find {
it.immutableClass.type == classDef.type
} ?: ClassProxy(classDef).also { proxyPool.add(it) }
}
fun proxy(classDef: ClassDef) = synchronized(classes.proxyPool) {
classes.proxyPool.find { it.immutableClass.type == classDef.type }
?: ClassProxy(classDef).also { classes.proxyPool.add(it) }
}

/**
Expand Down

0 comments on commit 2ecec37

Please # to comment.