From f14fb762df28671b9a8ae0c11a10cbc9331412c3 Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 4 Apr 2020 16:00:48 +0100 Subject: [PATCH] Simplify InvokeSpecialTransformer We only need to check for the ACC_FINAL flag once at the start of transformCode(), given the insn.owner == clazz.name condition. This change also removes the redundant getNode() call - we already have a reference to the ClassNode. Signed-off-by: Graham --- .../openrs2/deob/transform/InvokeSpecialTransformer.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/deob/src/main/java/dev/openrs2/deob/transform/InvokeSpecialTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/InvokeSpecialTransformer.kt index bdf504a5..64db8e94 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/InvokeSpecialTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/InvokeSpecialTransformer.kt @@ -22,6 +22,10 @@ class InvokeSpecialTransformer : Transformer() { } override fun transformCode(classPath: ClassPath, library: Library, clazz: ClassNode, method: MethodNode): Boolean { + if ((clazz.access and Opcodes.ACC_FINAL) == 0) { + return false + } + for (insn in method.instructions) { if (insn !is MethodInsnNode || insn.opcode != Opcodes.INVOKESPECIAL) { continue @@ -31,11 +35,6 @@ class InvokeSpecialTransformer : Transformer() { continue } - val owner = classPath.getNode(insn.owner)!! - if ((owner.access and Opcodes.ACC_FINAL) == 0) { - continue - } - insn.opcode = Opcodes.INVOKEVIRTUAL invokeSpecialsReplaced++ }