From 36eed51b90d4a5c3c79a317fe59e828050c7e3a0 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Thu, 10 Mar 2011 04:57:26 +0100 Subject: use config.get() only once instead of doing it at each iteration --- src/roster.py | 5 +++-- src/windows.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/roster.py b/src/roster.py index 5f927173..79de1868 100644 --- a/src/roster.py +++ b/src/roster.py @@ -149,14 +149,15 @@ class Roster(object): for the whole roster """ length = 0 + show_offline = config.get('roster_show_offline', 'false') == 'true' for group in self._roster_groups: - if config.get('roster_show_offline', 'false') == 'false' and group.get_nb_connected_contacts() == 0: + if not show_offline and group.get_nb_connected_contacts() == 0: continue length += 1 # One for the group's line itself if not group.folded: for contact in group.get_contacts(self._contact_filter): # We do not count the offline contacts (depending on config) - if config.get('roster_show_offline', 'false') == 'false' and\ + if not show_offline and\ contact.get_nb_resources() == 0: continue length += 1 # One for the contact's line diff --git a/src/windows.py b/src/windows.py index 3e073f9e..1b414b37 100644 --- a/src/windows.py +++ b/src/windows.py @@ -1257,8 +1257,9 @@ class RosterWin(Win): self._win.erase() self.draw_roster_information(roster) y = 1 + show_offline = config.get('roster_show_offline', 'false') == 'true' for group in roster.get_groups(): - if config.get('roster_show_offline', 'false') == 'false' and group.get_nb_connected_contacts() == 0: + if not show_offline and group.get_nb_connected_contacts() == 0: continue # Ignore empty groups # This loop is really REALLY ugly :^) if y-1 == self.pos: -- cgit v1.2.3