Skip to content

Commit

Permalink
perf: Use a map to merge integrations classes
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Oct 6, 2023
1 parent 444dee5 commit 6059d3c
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -108,16 +108,17 @@ 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,
integrations, BasicDexFileNamer(),
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
}
Expand All @@ -131,7 +132,6 @@ class BytecodeContext internal constructor(private val options: PatcherOptions)
}
}
}

clear()
}
}
Expand Down

0 comments on commit 6059d3c

Please sign in to comment.