]> gitweb.michael.orlitzky.com - hath.git/commitdiff
Use min_address to simplify some of the min_host cases.
authorMichael Orlitzky <michael@orlitzky.com>
Sun, 23 May 2010 16:25:15 +0000 (12:25 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Sun, 23 May 2010 16:25:15 +0000 (12:25 -0400)
src/Cidr.hs

index 14cefff09b4e2c2c94490ca857ee6bd23d38f842..41ea9ee9a711b6af63c928419f77a7363fbaf20e 100644 (file)
@@ -138,41 +138,15 @@ min_host (Cidr addr mask)
     | mask == Nine = addr { octet2 = apply_mask oct2 One,
                             octet3 = min_octet,
                             octet4 = min_octet }
-    | mask == Eight = addr { octet2 = min_octet,
-                             octet3 = min_octet,
-                             octet4 = min_octet }
-    | mask == Seven = addr { octet1 = apply_mask oct1 Seven,
-                             octet2 = min_octet,
-                             octet3 = min_octet,
-                             octet4 = min_octet }
-    | mask == Six = addr { octet1 = apply_mask oct1 Six,
-                           octet2 = min_octet,
-                           octet3 = min_octet,
-                           octet4 = min_octet }
-    | mask == Five = addr { octet1 = apply_mask oct1 Five,
-                            octet2 = min_octet,
-                            octet3 = min_octet,
-                            octet4 = min_octet }
-    | mask == Four = addr { octet1 = apply_mask oct1 Four,
-                            octet2 = min_octet,
-                            octet3 = min_octet,
-                            octet4 = min_octet }
-    | mask == Three = addr { octet1 = apply_mask oct1 Three,
-                             octet2 = min_octet,
-                             octet3 = min_octet,
-                             octet4 = min_octet }
-    | mask == Two = addr { octet1 = apply_mask oct1 Two,
-                           octet2 = min_octet,
-                           octet3 = min_octet,
-                           octet4 = min_octet }
-    | mask == One = addr { octet1 = apply_mask oct1 One,
-                           octet2 = min_octet,
-                           octet3 = min_octet,
-                           octet4 = min_octet }
-    | mask == Zero = addr { octet1 = min_octet,
-                            octet2 = min_octet,
-                            octet3 = min_octet,
-                            octet4 = min_octet }
+    | mask == Eight = min_address { octet1 = oct1 }
+    | mask == Seven = min_address { octet1 = apply_mask oct1 Seven }
+    | mask == Six = min_address { octet1 = apply_mask oct1 Six }
+    | mask == Five = min_address { octet1 = apply_mask oct1 Five }
+    | mask == Four = min_address { octet1 = apply_mask oct1 Four }
+    | mask == Three = min_address { octet1 = apply_mask oct1 Three }
+    | mask == Two = min_address { octet1 = apply_mask oct1 Two }
+    | mask == One = min_address { octet1 = apply_mask oct1 One }
+    | mask == Zero = min_address
     | otherwise = addr
     where
       oct1 = (octet1 addr)