use config.get() only once instead of doing it at each iteration
This commit is contained in:
parent
a519b90cba
commit
36eed51b90
2 changed files with 5 additions and 3 deletions
|
@ -149,14 +149,15 @@ class Roster(object):
|
||||||
for the whole roster
|
for the whole roster
|
||||||
"""
|
"""
|
||||||
length = 0
|
length = 0
|
||||||
|
show_offline = config.get('roster_show_offline', 'false') == 'true'
|
||||||
for group in self._roster_groups:
|
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
|
continue
|
||||||
length += 1 # One for the group's line itself
|
length += 1 # One for the group's line itself
|
||||||
if not group.folded:
|
if not group.folded:
|
||||||
for contact in group.get_contacts(self._contact_filter):
|
for contact in group.get_contacts(self._contact_filter):
|
||||||
# We do not count the offline contacts (depending on config)
|
# 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:
|
contact.get_nb_resources() == 0:
|
||||||
continue
|
continue
|
||||||
length += 1 # One for the contact's line
|
length += 1 # One for the contact's line
|
||||||
|
|
|
@ -1257,8 +1257,9 @@ class RosterWin(Win):
|
||||||
self._win.erase()
|
self._win.erase()
|
||||||
self.draw_roster_information(roster)
|
self.draw_roster_information(roster)
|
||||||
y = 1
|
y = 1
|
||||||
|
show_offline = config.get('roster_show_offline', 'false') == 'true'
|
||||||
for group in roster.get_groups():
|
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
|
continue # Ignore empty groups
|
||||||
# This loop is really REALLY ugly :^)
|
# This loop is really REALLY ugly :^)
|
||||||
if y-1 == self.pos:
|
if y-1 == self.pos:
|
||||||
|
|
Loading…
Reference in a new issue