diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2015-04-29 21:20:08 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2015-04-29 21:20:08 +0200 |
commit | 499f36a7cf8d545693bcb5946408ff8a007ddac9 (patch) | |
tree | ddd558ae56919a627f5cfa5235a21bb5b7be12a1 /src/plugins | |
parent | 9793649e7904c83ecfa60135b46f5812a7074d43 (diff) | |
download | weechat-499f36a7cf8d545693bcb5946408ff8a007ddac9.zip |
irc: optimize search of a nick in nicklist (up to 3x faster)
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/irc/irc-buffer.c | 18 | ||||
-rw-r--r-- | src/plugins/irc/irc-channel.c | 2 | ||||
-rw-r--r-- | src/plugins/irc/irc-upgrade.c | 10 |
3 files changed, 26 insertions, 4 deletions
diff --git a/src/plugins/irc/irc-buffer.c b/src/plugins/irc/irc-buffer.c index c7daa2c23..41491f10e 100644 --- a/src/plugins/irc/irc-buffer.c +++ b/src/plugins/irc/irc-buffer.c @@ -180,12 +180,22 @@ irc_buffer_nickcmp_cb (void *data, const char *nick1, const char *nick2) { - IRC_BUFFER_GET_SERVER(buffer); + struct t_irc_server *server; - /* make C compiler happy */ - (void) data; + if (data) + server = (struct t_irc_server *)data; + else + irc_buffer_get_server_and_channel (buffer, &server, NULL); - return irc_server_strcasecmp (ptr_server, nick1, nick2); + if (server) + { + return irc_server_strcasecmp (server, nick1, nick2); + } + else + { + /* default is RFC 1459 casemapping comparison */ + return weechat_strcasecmp_range (nick1, nick2, 29); + } } /* diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c index 74bc9ba39..1a6bc7226 100644 --- a/src/plugins/irc/irc-channel.c +++ b/src/plugins/irc/irc-channel.c @@ -351,6 +351,8 @@ irc_channel_create_buffer (struct t_irc_server *server, weechat_buffer_set (ptr_buffer, "nicklist_display_groups", "0"); weechat_buffer_set_pointer (ptr_buffer, "nickcmp_callback", &irc_buffer_nickcmp_cb); + weechat_buffer_set_pointer (ptr_buffer, "nickcmp_callback_data", + server); } /* set highlights settings on channel buffer */ diff --git a/src/plugins/irc/irc-upgrade.c b/src/plugins/irc/irc-upgrade.c index 95b464f69..d62147520 100644 --- a/src/plugins/irc/irc-upgrade.c +++ b/src/plugins/irc/irc-upgrade.c @@ -245,6 +245,7 @@ irc_upgrade_set_buffer_callbacks () { struct t_infolist *infolist; struct t_gui_buffer *ptr_buffer; + struct t_irc_server *ptr_server; const char *type; infolist = weechat_infolist_get ("buffer", NULL, NULL); @@ -260,8 +261,17 @@ irc_upgrade_set_buffer_callbacks () type = weechat_buffer_get_string (ptr_buffer, "localvar_type"); if (type && (strcmp (type, "channel") == 0)) { + ptr_server = irc_server_search ( + weechat_buffer_get_string (ptr_buffer, + "localvar_server")); weechat_buffer_set_pointer (ptr_buffer, "nickcmp_callback", &irc_buffer_nickcmp_cb); + if (ptr_server) + { + weechat_buffer_set_pointer (ptr_buffer, + "nickcmp_callback_data", + ptr_server); + } } if (strcmp (weechat_infolist_string (infolist, "name"), IRC_RAW_BUFFER_NAME) == 0) |