Skip to content

Commit 36cb62b

Browse files
committed
feat(Utils): Refactor toString method retrieval in ClassDef
- Replace direct call to toStringMethod() with a search for the "toString" method in ClassDef. - This change improves clarity and ensures the correct method is being referenced. No breaking changes introduced.
1 parent 688fa01 commit 36cb62b

File tree

1 file changed

+1
-2
lines changed
  • patches/src/main/kotlin/app/revanced/patches/duolingo/shared

1 file changed

+1
-2
lines changed

patches/src/main/kotlin/app/revanced/patches/duolingo/shared/Utils.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
44
import app.revanced.patcher.patch.PatchException
55
import app.revanced.util.getReference
66
import app.revanced.util.indexOfFirstInstructionOrThrow
7-
import app.revanced.util.toStringMethod
87
import com.android.tools.smali.dexlib2.Opcode
98
import com.android.tools.smali.dexlib2.iface.ClassDef
109
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@@ -15,7 +14,7 @@ internal object Utils {
1514
// Gets field from toString() method with the following format:
1615
// toString() { return "[Class]([field1]=" + this.a + "[field2]=" + this.b + ... + ")"; }
1716
internal fun ClassDef.fieldFromToString(subStr: String): FieldReference {
18-
val toString = this.toStringMethod()
17+
val toString = this.methods.first { it.name == "toString" }
1918
val strIndex = toString.indexOfFirstInstructionOrThrow() {
2019
this.opcode == Opcode.CONST_STRING &&
2120
getReference<StringReference>()?.string?.contains(subStr) ?: false

0 commit comments

Comments
 (0)