Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorgan Collett <morgan.collett@gmail.com>2007-10-12 10:19:29 (GMT)
committer Morgan Collett <morgan.collett@gmail.com>2007-10-12 10:19:29 (GMT)
commit64340f33cf322ebcfdbf6349c14b2bd296a6c9d0 (patch)
tree1ad72287c50179694d2fe61ea92f4340e7202e3c
parentcafa662edc3194235865c297e5f64a3c6f596209 (diff)
Maintain local handle to buddy cache
-rw-r--r--activity.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/activity.py b/activity.py
index 2ce05e5..107102d 100644
--- a/activity.py
+++ b/activity.py
@@ -195,6 +195,7 @@ class HelloTube(ExportedGObject):
self.entered = False # Have we set up the tube?
self.helloworld = False # Trivial "game state"
self._get_buddy = get_buddy # Converts handle to Buddy object
+ self._handle_to_buddy = {} # Cache buddy handles
self.tube.watch_participants(self.participant_change_cb)
def participant_change_cb(self, added, removed):
@@ -204,8 +205,9 @@ class HelloTube(ExportedGObject):
buddy = self._get_buddy(handle)
if buddy is not None:
self._logger.debug('Buddy %s was added' % buddy.props.nick)
+ self._handle_to_buddy[handle] = buddy
for handle in removed:
- buddy = self._get_buddy(handle)
+ buddy = self._handle_to_buddy.pop(handle, None)
if buddy is not None:
self._logger.debug('Buddy %s was removed' % buddy.props.nick)
if not self.entered: