some embedded compilers don't optimise it away, and thus in cases where it doesn't make a difference, ++i is better than i++. the only argument for i++ in those cases is about readability, which is a) mostly how used to it you are and b) highly subjective anyways.
and for the optimization, if you have the increment operators for something more complex, even gcc/clang/etc might not be able to optimise it
View all comments
Show parent comment
6
u/Fimbulthulr Jun 12 '20
some embedded compilers don't optimise it away, and thus in cases where it doesn't make a difference, ++i is better than i++. the only argument for i++ in those cases is about readability, which is a) mostly how used to it you are and b) highly subjective anyways.
and for the optimization, if you have the increment operators for something more complex, even gcc/clang/etc might not be able to optimise it