From b594505ea7f32cc1643611ef145dd141ff3b3d81 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Fri, 25 May 2012 12:23:06 +0200 Subject: [PATCH] [lib] Optimise owl_mac_equals() MAC addresses are more likely to vary in the right octets than in the left octets, so we compare them starting from the end rather than from the beginning. --- libowlps/libowlps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libowlps/libowlps.c b/libowlps/libowlps.c index af8621d..f7c00d9 100644 --- a/libowlps/libowlps.c +++ b/libowlps/libowlps.c @@ -68,7 +68,7 @@ owl_bool owl_mac_equals(const uint8_t *const mac1, const uint8_t *const mac2) { int i ; - for (i = 0 ; i < ETHER_ADDR_LEN ; ++i) + for (i = ETHER_ADDR_LEN - 1 ; i >= 0 ; --i) if(mac1[i] != mac2[i]) return owl_false ; return owl_true ;