Skip to content

Commit

Permalink
[ETHERNET]: Optimize is_broadcast_ether_addr
Browse files Browse the repository at this point in the history
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 <shemminger@osdl.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
  • Loading branch information
Stephen Hemminger authored and Arnaldo Carvalho de Melo committed Nov 2, 2005
1 parent 450b5b1 commit 2407534
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions include/linux/etherdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 2407534

Please sign in to comment.