Procházet zdrojové kódy

comp_with_mask: Slight optimization: Avoid shifts if address matches full mask

Bryan Drewery před 8 roky
rodič
revize
3b2fe35f13
1 změnil soubory, kde provedl 4 přidání a 2 odebrání
  1. 4 2
      src/match.cc

+ 4 - 2
src/match.cc

@@ -236,11 +236,13 @@ comp_with_mask(void *addr, void *dest, unsigned int mask)
 {
   if (memcmp(addr, dest, mask >> 3) == 0)
   {
+    if (mask % 8 == 0)
+      return (1);
+
     int n = mask >> 3;
     int m = ((-1) << (8 - (mask % 8)));
 
-    if (mask % 8 == 0 ||
-       (((unsigned char *) addr)[n] & m) == (((unsigned char *) dest)[n] & m))
+    if ((((unsigned char *) addr)[n] & m) == (((unsigned char *) dest)[n] & m))
       return (1);
   }
   return (0);