Code review comment for lp:~mc-return/compiz/compiz.merge-performance-do-not-assign-values-that-are-never-used

Revision history for this message
MC Return (mc-return) wrote :

> IMO its good defensive coding practise to initialize every variable before use
> because it insures against further changes using uninitialized variables.
>
> I'd like to hear the converse argument though. I think the compiler will just
> optimize out any redundancy really.

I do not trust every compiler to be that intelligent. If you assign a value to a local variable and then several instructions later reassign another value to it, without having used the first, the compiler will probably do what he is told to and make this first redundant assignment...

Also it is really ugly to find something in the code like this:

mState = saveState;
mState = saveState;

...even if the compiler would remove that one probably...

« Back to merge proposal