From: Richard Knutsson <ricknu-0@student.ltu.se>
To: kernel-janitors@vger.kernel.org
Subject: Re: [KJ] [RFC] Regarding abs() and labs()
Date: Sat, 03 Feb 2007 02:22:29 +0000 [thread overview]
Message-ID: <45C3F1E5.8020600@student.ltu.se> (raw)
In-Reply-To: <45C3E1C8.2040105@student.ltu.se>
Randy Dunlap wrote:
> On Sat, 03 Feb 2007 02:13:44 +0100 Richard Knutsson wrote:
>
>
>> Hello all
>>
>> Just took a look at abs() and can not understand why it seem so
>> overcomplicated. Why not just:
>>
>> #define abs(x) ((x) < 0) ? -(x) : (x))
>>
>
> It's almost that simple. It just adds a local __x so that
> 'x' won't be evaluated multiple times as it would in the simpler
> version. Multiple evaluations (of an expression) (that could
> have side effects) would take more CPU horsepower and could
> have bad side effects as well.
>
You mean if x is ex a + b? In such case; why not use typeof instead of int?
What kind of side-effects are you talking about?
Richard Knutsson
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
next prev parent reply other threads:[~2007-02-03 2:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-03 1:13 [KJ] [RFC] Regarding abs() and labs() Richard Knutsson
2007-02-03 1:44 ` Randy Dunlap
2007-02-03 2:22 ` Richard Knutsson [this message]
2007-02-03 2:34 ` Randy Dunlap
2007-02-03 2:52 ` Richard Knutsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=45C3F1E5.8020600@student.ltu.se \
--to=ricknu-0@student.ltu.se \
--cc=kernel-janitors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.