summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2016-07-12 21:05:46 +0200
committermathieui <mathieui@mathieui.net>2016-07-12 21:05:46 +0200
commita548e2ff6df2abec1791464055deeb9976ca73f8 (patch)
tree07ca709d8e2dae1b453327b66b38ffa4d98dc913
parentd19f53c3e9c5c02773b9fb3cdfe68a3cb245c833 (diff)
downloadpoezio-a548e2ff6df2abec1791464055deeb9976ca73f8.tar.gz
poezio-a548e2ff6df2abec1791464055deeb9976ca73f8.tar.bz2
poezio-a548e2ff6df2abec1791464055deeb9976ca73f8.tar.xz
poezio-a548e2ff6df2abec1791464055deeb9976ca73f8.zip
Improve refresh performance in big rooms
going through a list with more than 1000 elements, one at a time, can be a bit tedious. Especially if you go through it every time you receive one of those elements.
-rw-r--r--poezio/core/handlers.py2
-rw-r--r--poezio/tabs/muctab.py6
-rw-r--r--poezio/windows/info_wins.py19
3 files changed, 12 insertions, 15 deletions
diff --git a/poezio/core/handlers.py b/poezio/core/handlers.py
index 70c2e59c..e1fc292b 100644
--- a/poezio/core/handlers.py
+++ b/poezio/core/handlers.py
@@ -532,7 +532,7 @@ class HandlerCore:
if tab is self.core.current_tab():
tab.text_win.refresh()
- tab.info_header.refresh(tab, tab.text_win)
+ tab.info_header.refresh(tab, tab.text_win, user=tab.own_user)
tab.input.refresh()
self.core.doupdate()
elif tab.state != old_state:
diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py
index b6f55f7c..7ec7935c 100644
--- a/poezio/tabs/muctab.py
+++ b/poezio/tabs/muctab.py
@@ -59,6 +59,7 @@ class MucTab(ChatTab):
if self.joined == False:
self._state = 'disconnected'
self.own_nick = nick
+ self.own_user = None
self.name = jid
self.password = password
self.users = []
@@ -958,7 +959,7 @@ class MucTab(ChatTab):
if display_user_list:
self.v_separator.refresh()
self.user_win.refresh(self.users)
- self.info_header.refresh(self, self.text_win)
+ self.info_header.refresh(self, self.text_win, user=self.own_user)
self.refresh_tab_win()
if display_info_win:
self.info_win.refresh()
@@ -1096,6 +1097,7 @@ class MucTab(ChatTab):
# ejabberd or every gateway in the world that just do
# not send a 110 status code with the presence
self.own_nick = from_nick
+ self.own_user = new_user
self.joined = True
if self.name in self.core.initial_joins:
self.core.initial_joins.remove(self.name)
@@ -1201,7 +1203,7 @@ class MucTab(ChatTab):
if self.core.current_tab() is self:
self.text_win.refresh()
self.user_win.refresh_if_changed(self.users)
- self.info_header.refresh(self, self.text_win)
+ self.info_header.refresh(self, self.text_win, user=self.own_user)
self.input.refresh()
self.core.doupdate()
diff --git a/poezio/windows/info_wins.py b/poezio/windows/info_wins.py
index 1d1b5683..4ca72449 100644
--- a/poezio/windows/info_wins.py
+++ b/poezio/windows/info_wins.py
@@ -213,14 +213,14 @@ class MucInfoWin(InfoWin):
def __init__(self):
InfoWin.__init__(self)
- def refresh(self, room, window=None):
+ def refresh(self, room, window=None, user=None):
log.debug('Refresh: %s', self.__class__.__name__)
self._win.erase()
self.write_room_name(room)
self.write_participants_number(room)
self.write_own_nick(room)
self.write_disconnected(room)
- self.write_role(room)
+ self.write_role(room, user)
if window:
self.print_scroll_position(window)
self.finish_line(get_theme().COLOR_INFORMATION_BAR)
@@ -252,21 +252,16 @@ class MucInfoWin(InfoWin):
return
self.addstr(truncate_nick(nick, 13), to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
- def write_role(self, room):
+ def write_role(self, room, user):
"""
Write our own role and affiliation
"""
- own_user = None
- for user in room.users:
- if user.nick == room.own_nick:
- own_user = user
- break
- if not own_user:
+ if not user:
return
txt = ' ('
- if own_user.affiliation != 'none':
- txt += own_user.affiliation+', '
- txt += own_user.role+')'
+ if user.affiliation != 'none':
+ txt += user.affiliation + ', '
+ txt += user.role + ')'
self.addstr(txt, to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
class ConversationStatusMessageWin(InfoWin):