refactor: Simplify fingerprint resolution

This commit is contained in:
oSumAtrIX 2023-09-13 04:13:38 +02:00
parent aa71146b1b
commit a1fbb7990f
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4
2 changed files with 5 additions and 2 deletions

View file

@ -183,7 +183,7 @@ class Patcher(
// TODO: Implement this in a more polymorphic way.
when (patch) {
is BytecodePatch -> {
patch.fingerprints.toList().resolveUsingLookupMap(context.bytecodeContext)
patch.fingerprints.resolveUsingLookupMap(context.bytecodeContext)
patch.execute(context.bytecodeContext)
}
is ResourcePatch -> {

View file

@ -159,9 +159,12 @@ abstract class MethodFingerprint(
* - Faster: Specify [accessFlags], [returnType] and [parameters].
* - Fastest: Specify [strings], with at least one string being an exact (non-partial) match.
*/
internal fun List<MethodFingerprint>.resolveUsingLookupMap(context: BytecodeContext) {
internal fun Set<MethodFingerprint>.resolveUsingLookupMap(context: BytecodeContext) {
if (methods.isEmpty()) throw PatchException("lookup map not initialized")
forEach { fingerprint ->
fingerprint.resolveUsingLookupMap(context)
}
for (fingerprint in this) {
fingerprint.resolveUsingLookupMap(context)
}