@@ -62,45 +62,47 @@ private static void checkInsn(MethodNode mth, InsnNode insn, List<InsnNode> toRe
6262 || insn .getResult () == null ) {
6363 return ;
6464 }
65-
6665 SSAVar sVar = insn .getResult ().getSVar ();
6766 InsnArg constArg ;
6867 Runnable onSuccess = null ;
69-
70- InsnType insnType = insn .getType ();
71- if (insnType == InsnType .CONST || insnType == InsnType .MOVE ) {
72- constArg = insn .getArg (0 );
73- if (!constArg .isLiteral ()) {
74- return ;
75- }
76- long lit = ((LiteralArg ) constArg ).getLiteral ();
77- if (lit == 0 && forbidNullInlines (sVar )) {
78- // all usages forbids inlining
79- return ;
68+ switch (insn .getType ()) {
69+ case CONST :
70+ case MOVE : {
71+ constArg = insn .getArg (0 );
72+ if (!constArg .isLiteral ()) {
73+ return ;
74+ }
75+ long lit = ((LiteralArg ) constArg ).getLiteral ();
76+ if (lit == 0 && forbidNullInlines (sVar )) {
77+ // all usages forbids inlining
78+ return ;
79+ }
80+ break ;
8081 }
81- } else if (insnType == InsnType .CONST_STR ) {
82- if (sVar .isUsedInPhi ()) {
83- return ;
82+ case CONST_STR : {
83+ String s = ((ConstStringNode ) insn ).getString ();
84+ FieldNode f = mth .getParentClass ().getConstField (s );
85+ if (f == null ) {
86+ InsnNode copy = insn .copyWithoutResult ();
87+ constArg = InsnArg .wrapArg (copy );
88+ } else {
89+ InsnNode constGet = new IndexInsnNode (InsnType .SGET , f .getFieldInfo (), 0 );
90+ constArg = InsnArg .wrapArg (constGet );
91+ constArg .setType (ArgType .STRING );
92+ onSuccess = () -> f .addUseIn (mth );
93+ }
94+ break ;
8495 }
85- String s = ((ConstStringNode ) insn ).getString ();
86- FieldNode f = mth .getParentClass ().getConstField (s );
87- if (f == null ) {
88- InsnNode copy = insn .copyWithoutResult ();
89- constArg = InsnArg .wrapArg (copy );
90- } else {
91- InsnNode constGet = new IndexInsnNode (InsnType .SGET , f .getFieldInfo (), 0 );
92- constArg = InsnArg .wrapArg (constGet );
93- constArg .setType (ArgType .STRING );
94- onSuccess = () -> f .addUseIn (mth );
96+ case CONST_CLASS : {
97+ if (sVar .isUsedInPhi ()) {
98+ return ;
99+ }
100+ constArg = InsnArg .wrapArg (insn .copyWithoutResult ());
101+ constArg .setType (ArgType .CLASS );
102+ break ;
95103 }
96- } else if (insnType == InsnType .CONST_CLASS ) {
97- if (sVar .isUsedInPhi ()) {
104+ default :
98105 return ;
99- }
100- constArg = InsnArg .wrapArg (insn .copyWithoutResult ());
101- constArg .setType (ArgType .CLASS );
102- } else {
103- return ;
104106 }
105107
106108 // all check passed, run replace
0 commit comments