fix(youtube): improve patching speed (#2514)
This commit is contained in:

committed by
GitHub

parent
e9fb849d5f
commit
77bb761b0b
@ -1,16 +0,0 @@
|
||||
package app.revanced.util.patch
|
||||
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.Method
|
||||
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
|
||||
/**
|
||||
* @return the first constant instruction with the resource id, or -1 if not found.
|
||||
*/
|
||||
fun Method.indexOfFirstConstantInstruction(constantValue: Long): Int {
|
||||
return implementation?.let {
|
||||
it.instructions.indexOfFirst { instruction ->
|
||||
instruction.opcode == Opcode.CONST && (instruction as WideLiteralInstruction).wideLiteral == constantValue
|
||||
}
|
||||
} ?: -1
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package app.revanced.util.patch
|
||||
|
||||
import app.revanced.extensions.containsConstantInstructionValue
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
abstract class LiteralValueFingerprint(
|
||||
returnType: String? = null,
|
||||
accessFlags: Int? = null,
|
||||
parameters: Iterable<String>? = null,
|
||||
opcodes: Iterable<Opcode>? = null,
|
||||
strings: Iterable<String>? = null,
|
||||
literal: Long
|
||||
) : MethodFingerprint(
|
||||
returnType = returnType,
|
||||
accessFlags = accessFlags,
|
||||
parameters = parameters,
|
||||
opcodes = opcodes,
|
||||
strings = strings,
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.containsConstantInstructionValue(literal)
|
||||
}
|
||||
)
|
Reference in New Issue
Block a user