[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: Krazy: prefix vs. postfix ++ and -- operators
From: Rafał Miłecki <zajec5 () gmail ! com>
Date: 2011-01-11 15:25:50
Message-ID: AANLkTikQfccCiMPRvqOdPW8RU_L8-EOEMUK0igvcjvL= () mail ! gmail ! com
[Download RAW message or body]
2011/1/11 Christoph Feck <christoph@maxiom.de>:
> 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.
--
Rafał
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic