Skip to content

Commit

Permalink
perf: Use smallest lookup map for strings
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Nov 5, 2024
1 parent 6712f0e commit 1358d3f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/main/kotlin/app/revanced/patcher/Fingerprint.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,16 @@ class Fingerprint internal constructor(
internal fun matchOrNull(): Match? {
if (_matchOrNull != null) return _matchOrNull

val lookupMaps = lookupMaps

// Find the first
var match = strings?.firstNotNullOfOrNull { lookupMaps.methodsByStrings[it] }?.let { methodClasses ->
var match = strings?.mapNotNull {
lookupMaps.methodsByStrings[it]
}?.minByOrNull { it.size }?.let { methodClasses ->
methodClasses.forEach { (classDef, method) ->
val match = matchOrNull(classDef, method)
if (match != null) return@let match
}

null
}

if (match != null) return match

classes.forEach { classDef ->
Expand Down

0 comments on commit 1358d3f

Please sign in to comment.