Is a += b more efficient than a = a + b in C?

前端 未结 7 1731
耶瑟儿~
耶瑟儿~ 2020-12-10 04:42

I know in some languages the following:

a += b

is more efficient than:

a = a + b

because it removes the n

7条回答
  •  萌比男神i
    2020-12-10 05:05

    Other than with a truly ancient or incompetently written compiler there should be no difference, as long as a and b are normal variables so the two produce equivalent results.

    If you were dealing with C++ rather than C, operator overloading would allow there to be more substantial differences though.

提交回复
热议问题