aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTollef Fog Heen <tfheen@err.no>2016-10-03 21:12:34 +0200
committerTollef Fog Heen <tfheen@err.no>2016-10-03 21:12:34 +0200
commit0f1613d5eac212e07b2751e7a999656afc642443 (patch)
tree8afb0895d8dac5c9d911393061c33f77684de7d1 /wee_slack.py
parent128f1dc945790cffd65a874d6746644ac919ba2a (diff)
downloadwee-slack-0f1613d5eac212e07b2751e7a999656afc642443.tar.gz
Performance: fetch user object only once
Instead of lookup up the user object a bunch of times in buffer_prnt, just fetch it once.
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/wee_slack.py b/wee_slack.py
index fe18ac9..b2804b7 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -658,6 +658,7 @@ class Channel(object):
set_read_marker = False
time_float = float(time)
tags = "nick_" + user
+ user_obj = self.server.users.find(user)
# XXX: we should not set log1 for robots.
if time_float != 0 and self.last_read >= time_float:
tags += ",no_highlight,notify_none,logger_backlog_end"
@@ -678,16 +679,16 @@ class Channel(object):
if self.channel_buffer:
prefix_same_nick = w.config_string(w.config_get('weechat.look.prefix_same_nick'))
if user == self.last_active_user and prefix_same_nick != "":
- if colorize_nicks and self.server.users.find(user):
- name = self.server.users.find(user).color + prefix_same_nick
+ if colorize_nicks and user_obj:
+ name = user_obj.color + prefix_same_nick
else:
name = prefix_same_nick
else:
nick_prefix = w.config_string(w.config_get('weechat.look.nick_prefix'))
nick_suffix = w.config_string(w.config_get('weechat.look.nick_suffix'))
- if self.server.users.find(user):
- name = self.server.users.find(user).formatted_name()
+ if user_obj:
+ name = user_obj.formatted_name()
self.last_active_user = user
# XXX: handle bots properly here.
else:
@@ -700,8 +701,8 @@ class Channel(object):
if type(message) is not unicode:
message = message.decode('UTF-8', 'replace')
curr_color = w.color(chat_color)
- if colorize_nicks and colorize_messages and self.server.users.find(user):
- curr_color = self.server.users.find(user).color
+ if colorize_nicks and colorize_messages and user_obj:
+ curr_color = user_obj.color
message = curr_color + message
for user in self.server.users:
if user.name in message: