Should we still be optimizing “in the small”?

后端 未结 22 2134
旧时难觅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:46

    An interesting observation I've had over the years is that optimized code of one generation back seems to actually be counter-optimized in the following generation. This is i.e. due to processor implementations changing so that if/else becomes a bottleneck in modern CPUs, where pipelines are deep. I would say clean, short, concise code is often the best end result. Where optimization really counts is in the data structures, to get them right and slim.

提交回复
热议问题