Understanding more about i++ and i=i+1

后端 未结 4 1041
Happy的楠姐
Happy的楠姐 2021-02-14 08:54

I was wondering if there is difference between the two forms of increment. Some of the links says i++ is faster that i=i+1;

Also as one of the person my observation is

4条回答
  •  梦毁少年i
    2021-02-14 09:28

    There is no official document. The c spec does not declare that i++ must be faster than i+1 so compilers/optimizers are free to do what they like (and they can make different choices based on surrounding code and optimization level).

    I use i++ because it's faster for me to read, with fewer characters to mistype.

提交回复
热议问题