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 committed Apr 9, 2022
1 parent 32e6458 commit aed4fd9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/kotlin/app/revanced/patcher/Patcher.kt
Original file line number Diff line number Diff line change
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 aed4fd9

Please sign in to comment.