lkml.org 
[lkml]   [2013]   [Dec]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH net-next] ether_addr_equal: Optimize implementation, remove unused compare_ether_addr
From
Date
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))));

!!!? :)




\
 
 \ /
  Last update: 2013-12-06 01:41    [W:0.077 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site