lkml.org 
[lkml]   [2000]   [Aug]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] af_rose.c: s/suser/capable/ + micro cleanups
Date
From
Linus Torvalds wrote:
> actually prefer
>
> if (complex_test)
> return complex_expression1;
>
> return complex_expression2;
>
> over
>
> return (complex_test) ? complex_expression1 : complex_expression2;


Trade offs trade offs...

Compare:

int mr (unsigned int rate, int r)
{
int e = 16+9;
static int round[4]={0, 0, 0xffff, 0x8000};
if (!rate) return 0;
for (; rate & 0xfc000000 ;rate >>= 1, e++);
for (;!(rate & 0xfe000000);rate <<= 1, e--);
return ((rate & ~0x02000000) | (e << (16+9)) + round[r]) >> 16;
}

Dense code, right? Floating point in the kernel.... Aaargh.

Compare that with one hundred and twenty heavily commented lines in
drivers/atm/ambassador.c ..... (A very neat driver, by the way,
although you don't need 120 lines of code to do the above....)

Roger.

--
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
* Common sense is the collection of *
****** prejudices acquired by age eighteen. -- Albert Einstein ********
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:38    [W:0.080 / U:6.552 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site