Ö
Öö Tiib
I prefer to write "i++" rather than "++i", but that's a matter of taste.
Arguably it is best to write "++i" rather than getting into the had
habit of "i++".
Lot of people seem to have same taste as you.
As for code differences, a compiler doesn't need much optimising to
generate identical code for "i++" and "++i" when "i" is an integer type
and you are not using the value of the expression (in which case, code
will be different of course). It is not "optimising heavily" -
compilers should do this at even their most minimal optimisation levels,
which would certainly be enabled in normal usage.
I did not mean optimizing incrementing scalars like pointers or integers.
Such things have been parts of some other instruction (in style
"dereference and increment") in older processors. Modern processor
architectures have simpler operations and processors optimize (combine
and reorder) those.
Once you are talking about something other than an integer or pointer,
such as a class with overloaded operators, then there can be big
differences.
That was what I meant: there can be big differences in theory and it
can be measured from maliciously made code but there are no noticeable
differences in practice and when measuring algorithms of real code base.
The reasons are that the overloaded 'operator++'s are usually for
lightweight classes (numeric, counter, time, iterator) that are often
templates and the operators are often inline. On case of iterators
even using code is often inline (in <algorithm> etc.) That means
compilers have lot of opportunities to optimize there on common
case.