Re: GCC 3.4 Heads-up

From: Måns Rullgård
Date: Sun Jan 04 2004 - 20:41:46 EST


Bill Davidsen <davidsen@xxxxxxx> writes:

>> If you have local variables (register or not), the sane thing to do is
>> if (a)
>> b = d;
>> else
>> c = d;
>> or variations on that. That's the readable code.
>
> But may lead to errors in maintenence. Your first example below avoids
> that problem. Imagine instead of "d" you have a 40-50 character
> RHS. Now imagine that the code needs to be changed. If you have the
> long expression in two places then it invites the possiblility of
> someone changing only one of them. You may never make mistakes, but
> the rest of us do, and the conditional LHS avoids that.

What's wrong with

d = long_expression;
if (a)
b = d;
else
c = d;

Your long expression is still only in one place.

--
Måns Rullgård
mru@xxxxxx

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/