1
mirror of https://github.com/revanced/revanced-patcher synced 2025-01-27 01:28:36 +01:00

perf: use Set instead of List since there are no dupes

This commit is contained in:
Lucaskyy 2022-04-09 22:31:32 +02:00 committed by oSumAtrIX
parent 5bd416b409
commit e65ebd27c2
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4

View File

@ -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()
}