1
mirror of https://github.com/revanced/revanced-patcher synced 2024-11-20 16:19:21 +01:00

perf: Use smallest lookup map for strings

This commit is contained in:
oSumAtrIX 2024-11-05 14:39:06 +01:00
parent 6712f0ea72
commit 1358d3fa10
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4

View File

@ -72,10 +72,9 @@ 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
@ -83,7 +82,6 @@ class Fingerprint internal constructor(
null
}
if (match != null) return match
classes.forEach { classDef ->