summaryrefslogtreecommitdiff
path: root/sleekxmpp/roster/single.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-03-05 11:11:35 -0800
committerLance Stout <lancestout@gmail.com>2012-03-05 11:11:35 -0800
commitbe7f07ad1231b30bf953f0761773af46db952c62 (patch)
treea8e37d9e367d78a58615d757da58bef08d5ae626 /sleekxmpp/roster/single.py
parent830db11b4164410d792255eb9cf2f96779e86520 (diff)
downloadslixmpp-be7f07ad1231b30bf953f0761773af46db952c62.tar.gz
slixmpp-be7f07ad1231b30bf953f0761773af46db952c62.tar.bz2
slixmpp-be7f07ad1231b30bf953f0761773af46db952c62.tar.xz
slixmpp-be7f07ad1231b30bf953f0761773af46db952c62.zip
Prevent excess loading from the roster db.
Fixes issue #148
Diffstat (limited to 'sleekxmpp/roster/single.py')
-rw-r--r--sleekxmpp/roster/single.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/sleekxmpp/roster/single.py b/sleekxmpp/roster/single.py
index 633f23f6..611f8944 100644
--- a/sleekxmpp/roster/single.py
+++ b/sleekxmpp/roster/single.py
@@ -109,10 +109,13 @@ class RosterNode(object):
db -- The new datastore interface.
"""
self.db = db
- for jid in self.db.entries(self.jid):
- self.add(jid)
- for jid in self._jids:
+ existing_entries = set(self._jids)
+ new_entries = set(self.db.entries(self.jid, {}))
+
+ for jid in existing_entries:
self._jids[jid].set_backend(db)
+ for jid in new_entries - existing_entries:
+ self.add(jid)
def add(self, jid, name='', groups=None, afrom=False, ato=False,
pending_in=False, pending_out=False, whitelisted=False,