Performance difference of “if if” vs “if else if”

前端 未结 7 1663
遥遥无期
遥遥无期 2020-12-05 17:25

I was just thinking is there any performance difference between the 2 statements in C/C++:

Case 1:

if (p==0)
   do_this();
else if (p==1)
   do_that(         


        
7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 18:17

    In the former case conditions after the one matched are not evaluated.

提交回复
热议问题