From 6059d3ca2685cb659023b171b95d4b9d279c6e53 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 7 Oct 2023 01:52:21 +0200 Subject: [PATCH] perf: Use a map to merge integrations classes --- .../kotlin/app/revanced/patcher/data/BytecodeContext.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/revanced-patcher/src/main/kotlin/app/revanced/patcher/data/BytecodeContext.kt b/revanced-patcher/src/main/kotlin/app/revanced/patcher/data/BytecodeContext.kt index 34a694ec..fd6a131f 100644 --- a/revanced-patcher/src/main/kotlin/app/revanced/patcher/data/BytecodeContext.kt +++ b/revanced-patcher/src/main/kotlin/app/revanced/patcher/data/BytecodeContext.kt @@ -108,7 +108,8 @@ class BytecodeContext internal constructor(private val options: PatcherOptions) logger.info("Merging integrations") - // TODO: Multi-thread this. + val classMap = classes.associateBy { it.type } + this@Integrations.forEach { integrations -> MultiDexIO.readDexFile( true, @@ -116,8 +117,8 @@ class BytecodeContext internal constructor(private val options: PatcherOptions) null, null ).classes.forEach classDef@{ classDef -> - val existingClass = classes.find { it.type == classDef.type } ?: run { - logger.fine("Merging $classDef") + val existingClass = classMap[classDef.type] ?: run { + logger.fine("Adding $classDef") classes.add(classDef) return@classDef } @@ -131,7 +132,6 @@ class BytecodeContext internal constructor(private val options: PatcherOptions) } } } - clear() } }