Skip to content

Commit 1358d3f

Browse files
committed
perf: Use smallest lookup map for strings
1 parent 6712f0e commit 1358d3f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/main/kotlin/app/revanced/patcher/Fingerprint.kt

+3-5
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,16 @@ class Fingerprint internal constructor(
7272
internal fun matchOrNull(): Match? {
7373
if (_matchOrNull != null) return _matchOrNull
7474

75-
val lookupMaps = lookupMaps
76-
77-
// Find the first
78-
var match = strings?.firstNotNullOfOrNull { lookupMaps.methodsByStrings[it] }?.let { methodClasses ->
75+
var match = strings?.mapNotNull {
76+
lookupMaps.methodsByStrings[it]
77+
}?.minByOrNull { it.size }?.let { methodClasses ->
7978
methodClasses.forEach { (classDef, method) ->
8079
val match = matchOrNull(classDef, method)
8180
if (match != null) return@let match
8281
}
8382

8483
null
8584
}
86-
8785
if (match != null) return match
8886

8987
classes.forEach { classDef ->

0 commit comments

Comments
 (0)