?: Operator Vs. If Statement Performance

后端 未结 7 837
轻奢々
轻奢々 2020-12-05 23:18

I\'ve been trying to optimize my code to make it a little more concise and readable and was hoping I wasn\'t causing poorer performance from doing it. I think my changes mi

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-05 23:30

    I suspect there won't be any performance difference.

    Next to that, I wonder why you would have any concerns of favoring one statement over the other in this case ? I mean: the performance impact (if there should be any), would be minimal. IMHO, this would be a kind of micro-optimization, and it shouldn't be worth the effort.
    I would choose the statement that is most readable, most clear, and not worry about performance since it would be of minimal influence (in this case).

提交回复
热议问题