server: Performance improvements
When processing associations reduce the number of object manager
list searches from four to one.
Change-Id: I39603ca3cf22fd3090ef90be89690cad78d9ac4b
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/obmc/mapper/server.py b/obmc/mapper/server.py
index 72e1c53..08700c1 100644
--- a/obmc/mapper/server.py
+++ b/obmc/mapper/server.py
@@ -675,22 +675,23 @@
def update_association(self, path, removed, added):
iface = obmc.dbuslib.enums.OBMC_ASSOC_IFACE
- create = [] if self.manager.get(path, False) else [iface]
+ assoc = self.manager.get(path, None)
+ create = [] if assoc else [iface]
if added and create:
self.manager.add(
path, Association(self.bus, path, added))
+ assoc = self.manager.get(path)
elif added:
- self.manager.get(path).append(added)
+ assoc.append(added)
- obj = self.manager.get(path, None)
- if obj and removed:
- obj.remove(removed)
+ if assoc and removed:
+ assoc.remove(removed)
- if obj and not obj.endpoints:
+ delete = []
+ if assoc and not assoc.endpoints:
self.manager.remove(path)
-
- delete = [] if self.manager.get(path, False) else [iface]
+ delete = [iface]
if create != delete:
self.update_interfaces(