From 622138736dca6c0161171330801b7b5666594ec7 Mon Sep 17 00:00:00 2001 From: Lucaskyy Date: Sat, 9 Apr 2022 22:31:32 +0200 Subject: [PATCH] perf: use Set instead of List since there are no dupes --- src/main/kotlin/app/revanced/patcher/Patcher.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/app/revanced/patcher/Patcher.kt b/src/main/kotlin/app/revanced/patcher/Patcher.kt index 1fd7698d..a0f2ba77 100644 --- a/src/main/kotlin/app/revanced/patcher/Patcher.kt +++ b/src/main/kotlin/app/revanced/patcher/Patcher.kt @@ -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() + val classes = mutableSetOf() 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() }