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. // TODO: Implement this in a more polymorphic way.
when (patch) { when (patch) {
is BytecodePatch -> { is BytecodePatch -> {
patch.fingerprints.toList().resolveUsingLookupMap(context.bytecodeContext) patch.fingerprints.resolveUsingLookupMap(context.bytecodeContext)
patch.execute(context.bytecodeContext) patch.execute(context.bytecodeContext)
} }
is ResourcePatch -> { is ResourcePatch -> {

View File

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