Krazy: prefix vs. postfix ++ and -- operators

Rafał Miłecki zajec5 at
Tue Jan 11 15:25:50 GMT 2011

2011/1/11 Christoph Feck <christoph at>:
> Krazy says:
> "You should use ++ and -- as prefix whenever possible as these are more
> efficient than postfix operators. Prefix increments first and then uses the
> variable, postfix uses the actual; the variable is incremented as well.
> Because of this, the prefix operators are inherently more efficient."
> Considering that today's CPUs have multiple pipelines, using a value directly
> seems faster to me than waiting for it to be incremented or decremented.
> Is this krazy warning still correct?

Doesn't compiler optimize than anyway, when possible (like inside
for)? I was told that when I tried using post incr. in kernel.

However keeping one coding style is still great thing to think about.


More information about the kde-core-devel mailing list