changeset 4199041f5034 in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=4199041f5034 description: decrease call to get_contact(s) function to improve speed. see #7125
diffstat:
src/common/contacts.py | 2 +- src/roster_window.py | 29 ++++++++++++++++++----------- 2 files changed, 19 insertions(+), 12 deletions(-)
diffs (79 lines):
diff -r 682b687ebdc5 -r 4199041f5034 src/common/contacts.py --- a/src/common/contacts.py Sun Sep 23 13:34:21 2012 +0200 +++ b/src/common/contacts.py Mon Sep 24 12:24:10 2012 +0200 @@ -370,7 +370,7 @@ self.is_big_brother(account, jid, accounts): # count metacontacts only once continue - contact = self.get_contact_with_highest_priority(account, jid) + contact = self._accounts[account].contacts._contacts[jid][0] if _('Not in roster') in contact.groups: continue in_groups = False diff -r 682b687ebdc5 -r 4199041f5034 src/roster_window.py --- a/src/roster_window.py Sun Sep 23 13:34:21 2012 +0200 +++ b/src/roster_window.py Mon Sep 24 12:24:10 2012 +0200 @@ -1136,16 +1136,18 @@ self.draw_contact(parent_jid, parent_account) return False
- def draw_contact(self, jid, account, selected=False, focus=False): + def draw_contact(self, jid, account, selected=False, focus=False, contact_instances=None, contact=None): """ Draw the correct state image, name BUT not avatar """ # focus is about if the roster window has toplevel-focus or not # FIXME: We really need a custom cell_renderer
- contact_instances = gajim.contacts.get_contacts(account, jid) - contact = gajim.contacts.get_highest_prio_contact_from_contacts( - contact_instances) + if not contact_instances: + contact_instances = gajim.contacts.get_contacts(account, jid) + if not contact: + contact = gajim.contacts.get_highest_prio_contact_from_contacts( + contact_instances) if not contact: return False
@@ -1308,11 +1310,11 @@ else: return False
- def draw_all_pep_types(self, jid, account): + def draw_all_pep_types(self, jid, account, contact=None): for pep_type in self._pep_type_to_model_column: - self.draw_pep(jid, account, pep_type) - - def draw_pep(self, jid, account, pep_type): + self.draw_pep(jid, account, pep_type, contact=contact) + + def draw_pep(self, jid, account, pep_type, contact=None): if pep_type not in self._pep_type_to_model_column: return if not self._is_pep_shown_in_roster(pep_type): @@ -1322,7 +1324,8 @@ iters = self._get_contact_iter(jid, account, model=self.model) if not iters: return - contact = gajim.contacts.get_contact(account, jid) + if not contact: + contact = gajim.contacts.get_contact(account, jid) if pep_type in contact.pep: pixbuf = contact.pep[pep_type].asPixbufIcon() else: @@ -1345,8 +1348,12 @@ return False
def draw_completely(self, jid, account): - self.draw_contact(jid, account) - self.draw_all_pep_types(jid, account) + contact_instances = gajim.contacts.get_contacts(account, jid) + contact = gajim.contacts.get_highest_prio_contact_from_contacts( + contact_instances) + self.draw_contact(jid, account, contact_instances=contact_instances, + contact=contact) + self.draw_all_pep_types(jid, account, contact=contact) self.draw_avatar(jid, account)
def adjust_and_draw_contact_context(self, jid, account):