Is there is any difference between these two statements performance wise ?
i++;
i = i + 1;
Is there is any difference between these two statements performance wise ?
i++;
i = i + 1;
Depends on the optimisation. i++
can, on most processors, be represented as a single machine language instruction. i = i + 1
, on the other hand, could be represented by up to four: load i
, load 1
, add, store to i
; although, even a middling smart compiler should be able to recognise it can rewrite it into the former.
no, there is no difference. The compiler will compile these into the same assembly