From aed4fd9a3c9e7f96c1e2c54b831c3fe7d3d720a2 Mon Sep 17 00:00:00 2001 From: Lucaskyy Date: Sat, 9 Apr 2022 22:04:00 +0200 Subject: [PATCH] perf: use String List and compare instead of any lambda --- src/main/kotlin/app/revanced/patcher/Patcher.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/app/revanced/patcher/Patcher.kt b/src/main/kotlin/app/revanced/patcher/Patcher.kt index 533f89fb..1fd7698d 100644 --- a/src/main/kotlin/app/revanced/patcher/Patcher.kt +++ b/src/main/kotlin/app/revanced/patcher/Patcher.kt @@ -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() 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() } } /**