Avoid Postfix Increment Operator
Posted
by
muntoo
on Programmers
See other posts from Programmers
or by muntoo
Published on 2011-03-19T06:59:51Z
Indexed on
2011/03/19
8:17 UTC
Read the original article
Hit count: 298
I've read that I should avoid the postfix increment operator because of performance reasons (in certain cases).
But doesn't this affect code readability? In my opinion:
for(int i = 0; i < 42; i++);
/* i will never equal 42! */
Looks better than:
for(int i = 0; i < 42; ++i);
/* i will never equal 42! */
But this is probably just out of habit. Admittedly, I haven't seen many use ++i
.
Is the performance that bad to sacrifice readability, in this case? Or am I just blind, and ++i
is more readable than i++
?
© Programmers or respective owner