loop condition evaluation

前端 未结 3 671
北海茫月
北海茫月 2020-12-05 04:53

Just a quick question.

I have a loop that looks like this:

for (int i = 0; i < dim * dim; i++)

Is the condition in a for loop re

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-05 05:23

    In general, if you would for example change the value of "dim" inside your loop, it would be re-evaluated every time. But since that is not the case in your example, a decent compiler would optimize your code and you wouldn't see any difference in performance.

提交回复
热议问题