Prefer pre-increment and pre-decrementThis tip submitted by Karl on 2006-01-04 01:51:13. It has been viewed 14874 times.
Rating of 5.9 with 93 votes
As far as possible one should use ++i and --i rather than i++ or i--. In a nutshell one should always use the pre increment/decrement forms rather than the post ones.The reason being, post increment retains the old value (usually in a temporary variable) and usually one does not end up using the old value, so that temp variable ends up by just wasting instructions.
Thus always use the pre-increment/decrement statements rather than the post ones. This is most important for complex types like iterators. It tends to be mostly irrelevant for integers.
Help your fellow programmers! Add a tip!