summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2008-03-11 23:56:06 +0100
committerRené 'Necoro' Neumann <necoro@necoro.net>2008-03-11 23:56:06 +0100
commitce3998575855189e4fb87a8c9777397fac1ffa23 (patch)
tree1d594273eb44c52dfa356bbc001a0497cf668691
parent14efe88ba5ef199bbe0e57873898fcd75286a3ec (diff)
downloadportato-ce3998575855189e4fb87a8c9777397fac1ffa23.tar.gz
portato-ce3998575855189e4fb87a8c9777397fac1ffa23.tar.bz2
portato-ce3998575855189e4fb87a8c9777397fac1ffa23.zip
improved performance by caching the use_expand queries
-rw-r--r--portato/backend/catapult/package.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/portato/backend/catapult/package.py b/portato/backend/catapult/package.py
index 5da4361..5ab8743 100644
--- a/portato/backend/catapult/package.py
+++ b/portato/backend/catapult/package.py
@@ -29,6 +29,8 @@ class CatapultPackage(Package):
bus = dbus.SessionBus()
dbus_object = bus.get_object(catapult.get_dbus_address(catapult.DEFAULT), catapult.CATAPULT_PACKAGE_BUS, follow_name_owner_changes = True)
proxy = dbus.Interface(dbus_object, catapult.CATAPULT_PACKAGE_IFACE)
+
+ _expand = {}
def _new_flags (self):
flags = self.get_new_use_flags()
@@ -44,13 +46,20 @@ class CatapultPackage(Package):
return nflags
def use_expanded (self, flag, suggest = None):
- if not suggest:
- suggest = ""
- s = str(self.proxy.use_expanded(self.get_cpv(), flag, suggest))
- if s:
+
+ exp = self._expand.get(flag, False)
+
+ if exp is False:
+ if not suggest:
+ suggest = ""
+ s = str(self.proxy.use_expanded(self.get_cpv(), flag, suggest))
+ if not s:
+ s = None
+
+ self._expand[flag] = s
return s
else:
- return None
+ return exp
def get_package_path(self):
return str(self.proxy.get_package_path(self.get_cpv()))