VMM/common: Improve search_address complexity
authormartin f. krafft <madduck@debian.org>
Wed, 08 Aug 2012 14:37:29 +0000
changeset 586 cd1200d06700
parent 585 ffd24974ed68
child 587 8767ec854084
VMM/common: Improve search_address complexity Checking the dictionary (a hash) for existence of a key is likely to be O(log(n)), while checking a list is O(n). Therefore, to increase performance, this patch changes the check accordingly.
VirtualMailManager/common.py
--- a/VirtualMailManager/common.py	Tue Aug 07 23:55:41 2012 +0000
+++ b/VirtualMailManager/common.py	Wed Aug 08 14:37:29 2012 +0000
@@ -251,7 +251,7 @@
     gids = []
     daddrs = {}
     for gid, address, addrtype, aliasdomain in result:
-        if gid not in gids:
+        if gid not in daddrs:
             gids.append(gid)
             daddrs[gid] = []
         daddrs[gid].append((address, addrtype, aliasdomain))