x=x+1 vs. x +=1

后端 未结 17 1224
独厮守ぢ
独厮守ぢ 2020-12-29 02:57

I\'m under the impression that these two commands result in the same end, namely incrementing X by 1 but that the latter is probably more efficient.

If this is not c

17条回答
  •  -上瘾入骨i
    2020-12-29 03:21

    Back in the early 1980s, one of the really cool optimizations of the Lattice C Compiler was that "x = x + 1;", "x += 1;" and "x++;" all produced exactly the same machine code. If they could do it, a compiler written in this millenium should definitely be able to do it.

提交回复
热议问题