Skip to content

Commit

Permalink
perf: use Set instead of List since there are no dupes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sculas committed Apr 9, 2022
1 parent aed4fd9 commit 6221387
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/main/kotlin/app/revanced/patcher/Patcher.kt
Expand Up @@ -43,15 +43,14 @@ 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>()
val classes = mutableSetOf<String>()
for (classDef in dexFile.classes) {
if (classes.contains(classDef.type)) {
if (classes.add(classDef.type)) { // has duplicate
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 6221387

Please sign in to comment.