mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Joe Perches <joe@perches.com>
Cc: netdev@vger.kernel.org, Rob Landley <rob@landley.net>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] ether_addr_equal: Optimize implementation, remove unused compare_ether_addr
Date: Thu, 5 Dec 2013 15:32:29 -0800	[thread overview]
Message-ID: <20131205153229.187f7604@nehalam.linuxnetplumber.net> (raw)
In-Reply-To: <34a0bad292ab2535a3a2e757a83eca13408e55b7.1386283991.git.joe@perches.com>

On Thu,  5 Dec 2013 14:54:38 -0800
Joe Perches <joe@perches.com> wrote:

> +#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
> +	u32 fold = ((*(const u32 *)addr1) ^ (*(const u32 *)addr2)) |
> +		   ((*(const u16 *)(addr1 + 4)) ^ (*(const u16 *)(addr2 + 4)));
> +
> +	return fold == 0;

Why the temporary variable. You can just do:
	return ((*(const u32 *)addr1) ^ (*(const u32 *)addr2)) |
	       ((*(const u16 *)(addr1 + 4)) ^ (*(const u16 *)(addr2 + 4))) != 0;

Or
	return !!((*(const u32 *)addr1) ^ (*(const u32 *)addr2)) |
	         ((*(const u16 *)(addr1 + 4)) ^ (*(const u16 *)(addr2 + 4))));

  reply	other threads:[~2013-12-05 23:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-05 22:54 Joe Perches
2013-12-05 23:32 ` Stephen Hemminger [this message]
2013-12-05 23:36   ` Joe Perches
2013-12-06 21:37 ` David Miller

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=20131205153229.187f7604@nehalam.linuxnetplumber.net \
    --to=stephen@networkplumber.org \
    --cc=joe@perches.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rob@landley.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®