Krazy: prefix vs. postfix ++ and -- operators
Rafał Miłecki
zajec5 at gmail.com
Tue Jan 11 15:26:48 GMT 2011
W dniu 11 stycznia 2011 16:25 użytkownik Rafał Miłecki
<zajec5 at gmail.com> napisał:
> 2011/1/11 Christoph Feck <christoph at 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.
It should be "when I tried using pre incr. in kernel."
--
Rafał
More information about the kde-core-devel
mailing list