diff options
author | mathieui <mathieui@mathieui.net> | 2015-06-27 22:39:15 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2015-06-27 22:39:15 +0200 |
commit | 3b0cddd36801703d67ab1d9a2405ad9afc5431a4 (patch) | |
tree | 5b8174dfdd0be8226eff7052efa807fd736fa37b /src/core | |
parent | 22e2ba444e955d8f34170433f293f65f850419d0 (diff) | |
download | poezio-3b0cddd36801703d67ab1d9a2405ad9afc5431a4.tar.gz poezio-3b0cddd36801703d67ab1d9a2405ad9afc5431a4.tar.bz2 poezio-3b0cddd36801703d67ab1d9a2405ad9afc5431a4.tar.xz poezio-3b0cddd36801703d67ab1d9a2405ad9afc5431a4.zip |
Micro-optimize the roster refresh
The roster wrapper sucks and is way too slow. Halve refresh time by more
than 50% using manually managed counters.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/handlers.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/core/handlers.py b/src/core/handlers.py index f2df9a70..00e64ba8 100644 --- a/src/core/handlers.py +++ b/src/core/handlers.py @@ -867,7 +867,11 @@ def on_got_offline(self, presence): # If a resource got offline, display the message in the conversation with this # precise resource. contact = roster[jid.bare] - name = contact.name if contact and contact.name else jid.bare + name = jid.bare + if contact: + roster.connected -= 1 + if contact.name: + name = contact.name if jid.resource: self.add_information_message_to_conversation_tab(jid.full, '\x195}%s is \x191}offline' % name) self.add_information_message_to_conversation_tab(jid.bare, '\x195}%s is \x191}offline' % name) @@ -887,6 +891,7 @@ def on_got_online(self, presence): if contact is None: # Todo, handle presence coming from contacts not in roster return + roster.connected += 1 roster.modified() if not logger.log_roster_change(jid.bare, 'got online'): self.information('Unable to write in the log file', 'Error') |