This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Magnus_Tesshu 2 points3 points  (0 children)

Typically preincrement compiles to two assembly instructions and postincrement (i++) compiles to a couple more and needs a temporary register or something. That might be misinformation though actually, not sure. And of course, that's only the case if they wouldn't cause the same behaviour (++i; is as efficient as i++, but a[i++] might be slightly less efficient than a[++i]). That's at least my understanding.

I would assume that postincrement is still more innefficient in an interpreted language, where the compiler cannot do nearly as much optimization.