Skip to content

Commit

Permalink
perf: use String List and compare instead of any lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
Sculas authored and oSumAtrIX committed Jun 5, 2022
1 parent a6c6b49 commit 5bd416b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/kotlin/app/revanced/patcher/Patcher.kt
Expand Up @@ -43,14 +43,17 @@ class Patcher(
fun addFiles(vararg files: File, throwOnDuplicates: Boolean = false) {
for (file in files) {
val dexFile = MultiDexIO.readDexFile(true, files[0], NAMER, null, null)
val classes = mutableListOf<String>()
for (classDef in dexFile.classes) {
if (cache.classes.any { it.type == classDef.type }) {
// TODO: Use logger and warn about duplicate classes
if (classes.contains(classDef.type)) {
if (throwOnDuplicates)
throw Exception("Class ${classDef.type} has already been added to the patcher.")
continue
}
cache.classes.add(classDef)
classes.add(classDef.type)
}
classes.clear()
}
}
/**
Expand Down

0 comments on commit 5bd416b

Please sign in to comment.