summaryrefslogtreecommitdiff
path: root/src/windows/muc.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2015-05-08 20:37:21 +0200
committermathieui <mathieui@mathieui.net>2015-05-08 20:37:21 +0200
commitdfd60426d8da06c817c6d3f71901b4f1c013a819 (patch)
tree79fb8cf31b623cdd846311a0761b34a7b6cfb549 /src/windows/muc.py
parent3171c96eed40d24b3200a8f2af1da9bc7619ab39 (diff)
downloadpoezio-dfd60426d8da06c817c6d3f71901b4f1c013a819.tar.gz
poezio-dfd60426d8da06c817c6d3f71901b4f1c013a819.tar.bz2
poezio-dfd60426d8da06c817c6d3f71901b4f1c013a819.tar.xz
poezio-dfd60426d8da06c817c6d3f71901b4f1c013a819.zip
Micro-optimizations on refresh
Reduce the number of calls to config.get whenever possible. Yields a performance improvement of at least 10% for the basic use case of "receiving a message in the current tab". Logging stuff isn’t free either, even when the call should be a no-op, so we should try to make the debug log less verbose.
Diffstat (limited to 'src/windows/muc.py')
-rw-r--r--src/windows/muc.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/windows/muc.py b/src/windows/muc.py
index 7e3541ba..c4e8df6e 100644
--- a/src/windows/muc.py
+++ b/src/windows/muc.py
@@ -37,7 +37,8 @@ class UserList(Win):
if config.get('hide_user_list'):
return # do not refresh if this win is hidden.
self._win.erase()
- if config.get('user_list_sort').lower() == 'asc':
+ asc_sort = (config.get('user_list_sort').lower() == 'asc')
+ if asc_sort:
y, x = self._win.getmaxyx()
y -= 1
users = sorted(users)
@@ -55,7 +56,7 @@ class UserList(Win):
self.addstr(y, 2,
poopt.cut_by_columns(user.nick, self.width - 2),
to_curses_attr(user.color))
- if config.get('user_list_sort').lower() == 'asc':
+ if asc_sort:
y -= 1
else:
y += 1
@@ -63,12 +64,12 @@ class UserList(Win):
break
# draw indicators of position in the list
if self.pos > 0:
- if config.get('user_list_sort').lower() == 'asc':
+ if asc_sort:
self.draw_plus(self.height-1)
else:
self.draw_plus(0)
if self.pos + self.height < len(users):
- if config.get('user_list_sort').lower() == 'asc':
+ if asc_sort:
self.draw_plus(0)
else:
self.draw_plus(self.height-1)