[quake3-commits] r1947 - trunk/code/qcommon

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Mon Apr 25 22:30:12 EDT 2011


Author: thilo
Date: 2011-04-25 22:30:12 -0400 (Mon, 25 Apr 2011)
New Revision: 1947

Modified:
   trunk/code/qcommon/net_ip.c
Log:
Use memcmp instead of self-built while loop


Modified: trunk/code/qcommon/net_ip.c
===================================================================
--- trunk/code/qcommon/net_ip.c	2011-04-19 13:26:15 UTC (rev 1946)
+++ trunk/code/qcommon/net_ip.c	2011-04-26 02:30:12 UTC (rev 1947)
@@ -389,7 +389,6 @@
 */
 qboolean NET_CompareBaseAdrMask(netadr_t a, netadr_t b, int netmask)
 {
-	qboolean differed;
 	byte cmpmask, *addra, *addrb;
 	int curbyte;
 	
@@ -421,24 +420,12 @@
 		return qfalse;
 	}
 
-	differed = qfalse;
-	curbyte = 0;
+	curbyte = netmask >> 3;
 
-	while(netmask > 7)
-	{
-		if(addra[curbyte] != addrb[curbyte])
-		{
-			differed = qtrue;
-			break;
-		}
+	if(curbyte && memcmp(addra, addrb, curbyte))
+			return qfalse;
 
-		curbyte++;
-		netmask -= 8;
-	}
-
-	if(differed)
-		return qfalse;
-
+	netmask &= ~0x07;
 	if(netmask)
 	{
 		cmpmask = (1 << netmask) - 1;



More information about the quake3-commits mailing list