diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2007-05-28 14:54:40 (GMT) |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2007-05-28 14:54:40 (GMT) |
commit | aad2afdae21223bdc0e5cfe732fcd3b224d778fd (patch) | |
tree | b7acd2ff290be16f5303748882ac40b96736d485 /services | |
parent | 7aee70e047bd8150d0a549ada1beb66d34200152 (diff) |
services/presence/server_plugin: Use set operations to update the subscribe set
Diffstat (limited to 'services')
-rw-r--r-- | services/presence/server_plugin.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/services/presence/server_plugin.py b/services/presence/server_plugin.py index f0d988c..a1f93bf 100644 --- a/services/presence/server_plugin.py +++ b/services/presence/server_plugin.py @@ -857,16 +857,22 @@ class ServerPlugin(gobject.GObject): def _subscribe_members_changed_cb(self, added, removed, local_pending, remote_pending, actor, reason): - for handle in added: - self._subscribe_members.add(handle) - for handle in local_pending: - self._subscribe_local_pending.add(handle) - for handle in remote_pending: - self._subscribe_remote_pending.add(handle) - for handle in removed: - self._subscribe_members.discard(handle) - self._subscribe_local_pending.discard(handle) - self._subscribe_remote_pending.discard(handle) + + added = set(added) + removed = set(removed) + local_pending = set(local_pending) + remote_pending = set(remote_pending) + + affected = added|removed + affected |= local_pending + affected |= remote_pending + + self._subscribe_members -= affected + self._subscribe_members |= added + self._subscribe_local_pending -= affected + self._subscribe_local_pending |= local_pending + self._subscribe_remote_pending -= affected + self._subscribe_remote_pending |= remote_pending def _publish_members_changed_cb(self, added, removed, local_pending, remote_pending, actor, reason): |