perf: use String List and compare instead of any lambda

This commit is contained in:
Lucaskyy 2022-04-09 22:04:00 +02:00
parent 32e645850d
commit aed4fd9a3c
No known key found for this signature in database
GPG key ID: 1530BFF96D1EEB89

View file

@ -43,14 +43,17 @@ class Patcher(
fun addFiles(vararg files: File, throwOnDuplicates: Boolean = false) { fun addFiles(vararg files: File, throwOnDuplicates: Boolean = false) {
for (file in files) { for (file in files) {
val dexFile = MultiDexIO.readDexFile(true, files[0], NAMER, null, null) val dexFile = MultiDexIO.readDexFile(true, files[0], NAMER, null, null)
val classes = mutableListOf<String>()
for (classDef in dexFile.classes) { for (classDef in dexFile.classes) {
if (cache.classes.any { it.type == classDef.type }) { if (classes.contains(classDef.type)) {
// TODO: Use logger and warn about duplicate classes
if (throwOnDuplicates) if (throwOnDuplicates)
throw Exception("Class ${classDef.type} has already been added to the patcher.") throw Exception("Class ${classDef.type} has already been added to the patcher.")
continue
} }
cache.classes.add(classDef) cache.classes.add(classDef)
classes.add(classDef.type)
} }
classes.clear()
} }
} }
/** /**