Commit 8d2f2509 authored by Link Mauve's avatar Link Mauve

muctab: Create the last_talked compare lambda only once.

parent accf6ab7
...@@ -40,6 +40,8 @@ log = logging.getLogger(__name__) ...@@ -40,6 +40,8 @@ log = logging.getLogger(__name__)
NS_MUC_USER = 'http://jabber.org/protocol/muc#user' NS_MUC_USER = 'http://jabber.org/protocol/muc#user'
STATUS_XPATH = '{%s}x/{%s}status' % (NS_MUC_USER, NS_MUC_USER) STATUS_XPATH = '{%s}x/{%s}status' % (NS_MUC_USER, NS_MUC_USER)
COMPARE_USERS_LAST_TALKED = lambda x: x.last_talked
class MucTab(ChatTab): class MucTab(ChatTab):
""" """
...@@ -315,8 +317,7 @@ class MucTab(ChatTab): ...@@ -315,8 +317,7 @@ class MucTab(ChatTab):
return return
# Sort the user list by last talked, to avoid color conflicts # Sort the user list by last talked, to avoid color conflicts
# on active participants # on active participants
compare_users = lambda x: x.last_talked sorted_users = sorted(self.users, key=COMPARE_USERS_LAST_TALKED, reverse=True)
sorted_users = sorted(self.users, key=compare_users, reverse=True)
full_sorted_users = sorted_users[:] full_sorted_users = sorted_users[:]
# search our own user, to remove it from the list # search our own user, to remove it from the list
# Also remove users whose color is fixed # Also remove users whose color is fixed
...@@ -1625,9 +1626,8 @@ class MucTab(ChatTab): ...@@ -1625,9 +1626,8 @@ class MucTab(ChatTab):
# If we are not completing a command or a command argument, # If we are not completing a command or a command argument,
# complete a nick # complete a nick
compare_users = lambda x: x.last_talked
word_list = [] word_list = []
for user in sorted(self.users, key=compare_users, reverse=True): for user in sorted(self.users, key=COMPARE_USERS_LAST_TALKED, reverse=True):
if user.nick != self.own_nick: if user.nick != self.own_nick:
word_list.append(user.nick) word_list.append(user.nick)
after = config.get('after_completion') + ' ' after = config.get('after_completion') + ' '
...@@ -1650,9 +1650,8 @@ class MucTab(ChatTab): ...@@ -1650,9 +1650,8 @@ class MucTab(ChatTab):
def completion_version(self, the_input): def completion_version(self, the_input):
"""Completion for /version""" """Completion for /version"""
compare_users = lambda x: x.last_talked
userlist = [] userlist = []
for user in sorted(self.users, key=compare_users, reverse=True): for user in sorted(self.users, key=COMPARE_USERS_LAST_TALKED, reverse=True):
if user.nick != self.own_nick: if user.nick != self.own_nick:
userlist.append(user.nick) userlist.append(user.nick)
comp = [] comp = []
...@@ -1666,9 +1665,8 @@ class MucTab(ChatTab): ...@@ -1666,9 +1665,8 @@ class MucTab(ChatTab):
def completion_info(self, the_input): def completion_info(self, the_input):
"""Completion for /info""" """Completion for /info"""
compare_users = lambda x: x.last_talked
userlist = [] userlist = []
for user in sorted(self.users, key=compare_users, reverse=True): for user in sorted(self.users, key=COMPARE_USERS_LAST_TALKED, reverse=True):
userlist.append(user.nick) userlist.append(user.nick)
return Completion(the_input.auto_completion, userlist, quotify=False) return Completion(the_input.auto_completion, userlist, quotify=False)
...@@ -1766,9 +1764,8 @@ class MucTab(ChatTab): ...@@ -1766,9 +1764,8 @@ class MucTab(ChatTab):
def completion_quoted(self, the_input): def completion_quoted(self, the_input):
"""Nick completion, but with quotes""" """Nick completion, but with quotes"""
if the_input.get_argument_position(quoted=True) == 1: if the_input.get_argument_position(quoted=True) == 1:
compare_users = lambda x: x.last_talked
word_list = [] word_list = []
for user in sorted(self.users, key=compare_users, reverse=True): for user in sorted(self.users, key=COMPARE_USERS_LAST_TALKED, reverse=True):
if user.nick != self.own_nick: if user.nick != self.own_nick:
word_list.append(user.nick) word_list.append(user.nick)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment