From 797d127dfc0da5b445389d54b345aa2570294d69 Mon Sep 17 00:00:00 2001 From: Thilo Schulz Date: Tue, 26 Apr 2011 02:30:12 +0000 Subject: [PATCH] Use memcmp instead of self-built while loop --- code/qcommon/net_ip.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/code/qcommon/net_ip.c b/code/qcommon/net_ip.c index ce7a3252..2708e9b2 100644 --- a/code/qcommon/net_ip.c +++ b/code/qcommon/net_ip.c @@ -389,7 +389,6 @@ Compare without port, and up to the bit number given in netmask. */ qboolean NET_CompareBaseAdrMask(netadr_t a, netadr_t b, int netmask) { - qboolean differed; byte cmpmask, *addra, *addrb; int curbyte; @@ -421,24 +420,12 @@ qboolean NET_CompareBaseAdrMask(netadr_t a, netadr_t b, int netmask) return qfalse; } - differed = qfalse; - curbyte = 0; + curbyte = netmask >> 3; - while(netmask > 7) - { - if(addra[curbyte] != addrb[curbyte]) - { - differed = qtrue; - break; - } - - curbyte++; - netmask -= 8; - } - - if(differed) - return qfalse; + if(curbyte && memcmp(addra, addrb, curbyte)) + return qfalse; + netmask &= ~0x07; if(netmask) { cmpmask = (1 << netmask) - 1;