1
mirror of https://github.com/revanced/revanced-patcher synced 2025-02-14 09:24:27 +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? { internal fun matchOrNull(): Match? {
if (_matchOrNull != null) return _matchOrNull if (_matchOrNull != null) return _matchOrNull
val lookupMaps = lookupMaps var match = strings?.mapNotNull {
lookupMaps.methodsByStrings[it]
// Find the first }?.minByOrNull { it.size }?.let { methodClasses ->
var match = strings?.firstNotNullOfOrNull { lookupMaps.methodsByStrings[it] }?.let { methodClasses ->
methodClasses.forEach { (classDef, method) -> methodClasses.forEach { (classDef, method) ->
val match = matchOrNull(classDef, method) val match = matchOrNull(classDef, method)
if (match != null) return@let match if (match != null) return@let match
@ -83,7 +82,6 @@ class Fingerprint internal constructor(
null null
} }
if (match != null) return match if (match != null) return match
classes.forEach { classDef -> classes.forEach { classDef ->