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 <gpe@openrs2.dev>
bzip2
Graham 5 years ago
parent 7d985217ab
commit f14fb762df
  1. 9
      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 { 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) { for (insn in method.instructions) {
if (insn !is MethodInsnNode || insn.opcode != Opcodes.INVOKESPECIAL) { if (insn !is MethodInsnNode || insn.opcode != Opcodes.INVOKESPECIAL) {
continue continue
@ -31,11 +35,6 @@ class InvokeSpecialTransformer : Transformer() {
continue continue
} }
val owner = classPath.getNode(insn.owner)!!
if ((owner.access and Opcodes.ACC_FINAL) == 0) {
continue
}
insn.opcode = Opcodes.INVOKEVIRTUAL insn.opcode = Opcodes.INVOKEVIRTUAL
invokeSpecialsReplaced++ invokeSpecialsReplaced++
} }

Loading…
Cancel
Save