[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20111122145940.GA24909@p183.telecom.by>
Date: Tue, 22 Nov 2011 17:59:40 +0300
From: Alexey Dobriyan <adobriyan@...il.com>
To: David Laight <David.Laight@...LAB.COM>
Cc: davem@...emloft.net, netdev@...r.kernel.org
Subject: Re: [PATCH] xfrm: optimize ipv4 selector matching
On Tue, Nov 22, 2011 at 02:50:59PM -0000, David Laight wrote:
>
> > +static inline int addr4_match(const __be32 a1, const __be32
> > a2, const u8 prefixlen)
> > +{
> > + /* C99 6.5.7 (3): u32 << 32 is undefined behaviour */
> > + if (prefixlen == 0) {
> > + /* Matching constants result in smaller assembly. */
> > + return 0xFFFFFFFFu;
> > + }
> > + return !((a1 ^ a2) & htonl(0xFFFFFFFFu << (32 - prefixlen)));
> > +}
> > +
>
> It would probably be clearer to 'return 1' when prefixlen is zero.
"return 1" results in bigger code.
This function used only in boolean context, so exact return value doesn't matter.
> If this is a common path, might be worth caching
> htonl(0xFFFFFFFFu << (32 - prefixlen))
> in the enclosing structure.
This means one more branch, which wouldn't be a win compared
to current code.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists