All of lore.kernel.org
 help / color / mirror / Atom feed
From: lsorense@csclub.uwaterloo.ca (Lennart Sorensen)
To: Richard Knutsson <ricknu-0@student.ltu.se>
Cc: Paul Jimenez <pj@place.org>,
	rgooch@atnf.csiro.au, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mtrr use type bool
Date: Wed, 31 Oct 2007 12:20:16 -0400	[thread overview]
Message-ID: <20071031162016.GD27646@csclub.uwaterloo.ca> (raw)
In-Reply-To: <47289EE3.8080706@student.ltu.se>

On Wed, Oct 31, 2007 at 04:27:31PM +0100, Richard Knutsson wrote:
> Paul Jimenez wrote:
....
> >-			usage_table[i] = usage_table[replace] + !!increment;
> >+			usage_table[i] = usage_table[replace] + increment;
> >  
> This seems a bit strange, using a boolean as an integer (yes I know, it 
> works but semantically...). What about:
> 
> +			usage_table[i] = usage_table[replace];
> +			usage_table[i] += increment ? 1 : 0;

What is wrong with:
usage_table[i] = usage_table[replace];
if (increment)
	usage_table[i]++;

I hate code with the '?' operator in general.  It's a conditional either
way, and at least this way you wouldn't even have to do a store in one
of the two cases 9although if the compiler can't figure out that is the
case already, then it really sucks).

Pauls code at least didn't involve a conditional at all, but on the
other hand is less clear to read.

--
Len Sorensen

  reply	other threads:[~2007-10-31 16:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-31  3:57 [PATCH] mtrr use type bool Paul Jimenez
2007-10-31 15:27 ` Richard Knutsson
2007-10-31 16:20   ` Lennart Sorensen [this message]
2007-10-31 20:25     ` Richard Knutsson
2007-10-31 16:27   ` Paul Jimenez
2007-10-31 20:49     ` Richard Knutsson
2007-11-02 20:14       ` [PATCH] mtrr use type bool [RESEND] Paul Jimenez

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=20071031162016.GD27646@csclub.uwaterloo.ca \
    --to=lsorense@csclub.uwaterloo.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pj@place.org \
    --cc=rgooch@atnf.csiro.au \
    --cc=ricknu-0@student.ltu.se \
    /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.