From: Joe Perches <joe@perches.com>
To: Stephen Hemminger <stephen@networkplumber.org>
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, 05 Dec 2013 15:36:55 -0800 [thread overview]
Message-ID: <1386286615.10003.30.camel@joe-AO722> (raw)
In-Reply-To: <20131205153229.187f7604@nehalam.linuxnetplumber.net>
On Thu, 2013-12-05 at 15:32 -0800, Stephen Hemminger wrote:
> 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.
It's cost free and I think a bit more readable.
> You can just do:
> return ((*(const u32 *)addr1) ^ (*(const u32 *)addr2)) |
> ((*(const u16 *)(addr1 + 4)) ^ (*(const u16 *)(addr2 + 4))) != 0;
== 0
> Or
> return !!((*(const u32 *)addr1) ^ (*(const u32 *)addr2)) |
> ((*(const u16 *)(addr1 + 4)) ^ (*(const u16 *)(addr2 + 4))));
!!!? :)
next prev parent reply other threads:[~2013-12-05 23:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-05 22:54 [PATCH net-next] ether_addr_equal: Optimize implementation, remove unused compare_ether_addr Joe Perches
2013-12-05 23:32 ` Stephen Hemminger
2013-12-05 23:36 ` Joe Perches [this message]
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=1386286615.10003.30.camel@joe-AO722 \
--to=joe@perches.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rob@landley.net \
--cc=stephen@networkplumber.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox