From c56ac7a81f489bd5bff35de57d37c848ce56984d Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Thu, 27 Nov 2025 00:36:36 +0100 Subject: [PATCH] fix: Everything works now --- .../app/revanced/patcher/extensions/Method.kt | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/app/revanced/patcher/extensions/Method.kt b/src/main/kotlin/app/revanced/patcher/extensions/Method.kt index cc26883..297d81c 100644 --- a/src/main/kotlin/app/revanced/patcher/extensions/Method.kt +++ b/src/main/kotlin/app/revanced/patcher/extensions/Method.kt @@ -65,13 +65,7 @@ fun MutableMethodImplementation.removeInstructions(count: Int) = removeInstructi fun MutableMethodImplementation.replaceInstructions( index: Int, instructions: List, -) { - // Remove the instructions at the given index. - removeInstructions(index, instructions.size) - - // Add the instructions at the given index. - addInstructions(index, instructions) -} +) = instructions.forEach { replaceInstruction(index, it) } /** * Add an instruction to a method at the given index. @@ -100,14 +94,14 @@ fun MutableMethod.addInstruction(instruction: BuilderInstruction) = implementati fun MutableMethod.addInstruction( index: Int, smaliInstructions: String, -) = implementation!!.addInstructions(index, smaliInstructions.toInstructions(this)) +) = implementation!!.addInstruction(index, smaliInstructions.toInstructions(this).first()) /** * Add an instruction to a method. * * @param smaliInstructions The instruction to add. */ -fun MutableMethod.addInstruction(smaliInstructions: String) = implementation!!.addInstructions(smaliInstructions.toInstructions(this)) +fun MutableMethod.addInstruction(smaliInstructions: String) = implementation!!.addInstruction(smaliInstructions.toInstructions(this).first()) /** * Add instructions to a method at the given index. @@ -289,7 +283,7 @@ fun MutableMethod.replaceInstruction( fun MutableMethod.replaceInstruction( index: Int, smaliInstruction: String, -) = implementation!!.replaceInstructions(index, smaliInstruction.toInstructions(this)) +) = implementation!!.replaceInstruction(index, smaliInstruction.toInstructions(this).first()) /** * Replace instructions at the given index.