lkml.org 
[lkml]   [2004]   [Jan]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: GCC 3.4 Heads-up
Date
Bill Davidsen <davidsen@tmr.com> 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@kth.se

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

\
 
 \ /
  Last update: 2005-03-22 13:59    [W:0.112 / U:0.904 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site