Skip to content

Commit f15df5f

Browse files
fix: memory usage
Signed-off-by: androidacy-user <[email protected]>
1 parent 6a602b5 commit f15df5f

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99

1010
allprojects {
1111
group = "com.github.Androidacy.LSParanoid"
12-
version = "0.9.5"
12+
version = "0.9.6"
1313

1414
plugins.withType(JavaPlugin::class.java) {
1515
extensions.configure(JavaPluginExtension::class.java) {

processor/src/main/kotlin/org/lsposed/lsparanoid/processor/Patcher.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class Patcher(
9393
val reader = ClassReader(source.readFile(name))
9494
val writer = StandaloneClassWriter(
9595
reader,
96-
ClassWriter.COMPUTE_MAXS,
96+
ClassWriter.COMPUTE_FRAMES,
9797
classRegistry,
9898
fileRegistry
9999
)
@@ -116,7 +116,7 @@ class Patcher(
116116
it
117117
)
118118
}
119-
reader.accept(patcher, ClassReader.EXPAND_FRAMES)
119+
reader.accept(patcher, ClassReader.SKIP_FRAMES)
120120
jar.createFile(name, writer.toByteArray())
121121
return true
122122
}

processor/src/main/kotlin/org/lsposed/lsparanoid/processor/StandaloneClassWriter.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class StandaloneClassWriter : ClassWriter {
3131
private val logger = getLogger()
3232
private val classRegistry: ClassRegistry
3333
private val fileRegistry: FileRegistry
34+
private val superClassCache = HashMap<Pair<String, String>, String>()
3435

3536
constructor(
3637
flags: Int,
@@ -52,6 +53,17 @@ class StandaloneClassWriter : ClassWriter {
5253
}
5354

5455
override fun getCommonSuperClass(type1: String, type2: String): String {
56+
val key = Pair(type1, type2)
57+
superClassCache[key]?.let { return it }
58+
val reverseKey = Pair(type2, type1)
59+
superClassCache[reverseKey]?.let { return it }
60+
61+
val result = computeCommonSuperClass(type1, type2)
62+
superClassCache[key] = result
63+
return result
64+
}
65+
66+
private fun computeCommonSuperClass(type1: String, type2: String): String {
5567
val hierarchy = HashSet<Type>()
5668
for (mirror in classRegistry.findClassHierarchy(getObjectTypeByInternalName(type1))) {
5769
hierarchy.add(mirror.type)

0 commit comments

Comments
 (0)