From: Stephen Hemminger Date: Wed, 2 Nov 2005 00:52:11 +0000 (-0800) Subject: [ETHERNET]: Optimize is_broadcast_ether_addr X-Git-Tag: v2.6.15-rc1~452^2~26^2~4 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2407534f8be8015d585104bcc4374870b6b70fe7;p=linux-2.6 [ETHERNET]: Optimize is_broadcast_ether_addr Optimize the match for broadcast address by using bit operations instead of comparison. This saves a number of conditional branches, and generates smaller code. Signed-off-by: Stephen Hemminger Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h index cc84934f90..17460c85df 100644 --- a/include/linux/etherdevice.h +++ b/include/linux/etherdevice.h @@ -71,8 +71,7 @@ static inline int is_multicast_ether_addr(const u8 *addr) static inline int is_broadcast_ether_addr(const u8 *addr) { - return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && - (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); + return (addr[0] & addr[1] & addr[2] & addr[3] & addr[4] & addr[5]) == 0xff; } /**