if->return vs. if->else efficiency

后端 未结 6 1186
一整个雨季
一整个雨季 2020-12-28 12:35

This may sound like a silly question, and I hesitated to post it, but still: if something needs to run only in a certain condition, which of these is more efficient:

6条回答
  •  一整个雨季
    2020-12-28 13:18

    Please pick the thing that is most readable. Performance optimizations at this level are hardly ever an issue. Even really performance sensitive parts of frameworks (such as the .NET framework) do not benefit from such an micro optimization.

提交回复
热议问题