a==null vs null==a

public class A{
void a(){
String a = null;
if(a==null){}
}
void b(){
String a = null;
if(null==a){}
}
}

void a();
Code:
Stack=1, Locals=2, Args_size=1
0: aconst_null
1: astore_1
2: aload_1
3: ifnonnull 6
6: return
LineNumberTable:
line 3: 0
line 4: 2
line 5: 6

StackMapTable: number_of_entries = 1
frame_type = 252 /* append */
offset_delta = 6
locals = [ class java/lang/String ]


void b();
Code:
Stack=2, Locals=2, Args_size=1
0: aconst_null
1: astore_1
2: aconst_null
3: aload_1
4: if_acmpne 7
7: return
LineNumberTable:
line 7: 0
line 8: 2
line 9: 7

StackMapTable: number_of_entries = 1
frame_type = 252 /* append */
offset_delta = 7
locals = [ class java/lang/String ]


}

今天看到一段代码,类似b方法的调用,于是就开始掉过来哪个快点。从BC上看a方法要快一点。具体的性能测试还有待验证。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值