Replace postfix increment and decrement operators with their prefix equivalents #385
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is no reason whatsoever to use the postfix versions of the increment and decrement operator.
In postfix incrementing, first, a copy of the operand is made. Then the operand (not the copy) is incremented. Finally, the copy (not the original) is evaluated. Then the temporary copy is discarded. The postfix version takes a lot more steps, and thus may not be as performant as the prefix version.
In practice, any non-toy compiler will optimise away these steps and the postfix version is likely to have the same performance as the prefix versions for fundamental data types and even for compound types.
However, for user-defined data types where these operators may be overloaded, the postfix version is likely to be slower.
References
There should be no reason whatsoever to use these postfix operators, and we should strive to break this old habit asap.