Should we still be optimizing “in the small”?

后端 未结 22 2135
旧时难觅i
旧时难觅i 2020-12-05 11:32

I was changing my for loop to increment using ++i instead of i++ and got to thinking, is this really necessary anymore? Surely today\'s compilers

22条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 11:42

    I wanted to add a little something. This "premature optimization is bad" is kind of rubbish. What do you do when you select a algorithm? You probably take the one with the best time complexity - OMG premature optimization. Yet everyone seems fine with this. So it seems like the real attitude is "premature optimization is bad - unless you do it my way" At the end of the day do whatever you need to do to make the app you need to make.

    "The programmer shall left shift by one instead of multiplying by 2". hope you dont want to multiply floats or negative numbers then ;)

提交回复
热议问题