Don't analyze method in RNCE if there're no optimizable instructions
This commit is contained in:
+8
@@ -46,6 +46,8 @@ class RedundantNullCheckMethodTransformer : MethodTransformer() {
|
||||
private var changes = false
|
||||
|
||||
fun run(): Boolean {
|
||||
if (methodNode.instructions.toArray().none { it.isOptimizable() }) return false
|
||||
|
||||
val checkedReferenceTypes = analyzeTypesAndRemoveDeadCode()
|
||||
eliminateRedundantChecks(checkedReferenceTypes)
|
||||
|
||||
@@ -120,6 +122,12 @@ class RedundantNullCheckMethodTransformer : MethodTransformer() {
|
||||
return nullabilityMap
|
||||
}
|
||||
|
||||
private fun AbstractInsnNode.isOptimizable() =
|
||||
opcode == Opcodes.IFNULL ||
|
||||
opcode == Opcodes.IFNONNULL ||
|
||||
opcode == Opcodes.INSTANCEOF ||
|
||||
isCheckExpressionValueIsNotNull()
|
||||
|
||||
private fun transformTrivialChecks(nullabilityMap: Map<AbstractInsnNode, StrictBasicValue>) {
|
||||
for ((insn, value) in nullabilityMap) {
|
||||
val nullability = value.getNullability()
|
||||
|
||||
Reference in New Issue
Block a user