mirror of
https://github.com/irssi/irssi.git
synced 2024-10-27 05:20:20 -04:00
Merge pull request #705 from ailin-nemui/nicklist-performance
improve nicklist performance
This commit is contained in:
commit
476f19f123
@ -169,37 +169,39 @@ void nicklist_rename_unique(SERVER_REC *server,
|
|||||||
static NICK_REC *nicklist_find_wildcards(CHANNEL_REC *channel,
|
static NICK_REC *nicklist_find_wildcards(CHANNEL_REC *channel,
|
||||||
const char *mask)
|
const char *mask)
|
||||||
{
|
{
|
||||||
GSList *nicks, *tmp;
|
|
||||||
NICK_REC *nick;
|
NICK_REC *nick;
|
||||||
|
GHashTableIter iter;
|
||||||
|
|
||||||
nicks = nicklist_getnicks(channel);
|
g_hash_table_iter_init(&iter, channel->nicks);
|
||||||
nick = NULL;
|
while (g_hash_table_iter_next(&iter, NULL, (void*)&nick)) {
|
||||||
for (tmp = nicks; tmp != NULL; tmp = tmp->next) {
|
for (; nick != NULL; nick = nick->next) {
|
||||||
nick = tmp->data;
|
if (mask_match_address(channel->server, mask,
|
||||||
|
nick->nick, nick->host))
|
||||||
if (mask_match_address(channel->server, mask,
|
return nick;
|
||||||
nick->nick, nick->host))
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
g_slist_free(nicks);
|
|
||||||
return tmp == NULL ? NULL : nick;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
GSList *nicklist_find_multiple(CHANNEL_REC *channel, const char *mask)
|
GSList *nicklist_find_multiple(CHANNEL_REC *channel, const char *mask)
|
||||||
{
|
{
|
||||||
GSList *nicks, *tmp, *next;
|
GSList *nicks;
|
||||||
|
NICK_REC *nick;
|
||||||
|
GHashTableIter iter;
|
||||||
|
|
||||||
g_return_val_if_fail(IS_CHANNEL(channel), NULL);
|
g_return_val_if_fail(IS_CHANNEL(channel), NULL);
|
||||||
g_return_val_if_fail(mask != NULL, NULL);
|
g_return_val_if_fail(mask != NULL, NULL);
|
||||||
|
|
||||||
nicks = nicklist_getnicks(channel);
|
nicks = NULL;
|
||||||
for (tmp = nicks; tmp != NULL; tmp = next) {
|
|
||||||
NICK_REC *nick = tmp->data;
|
|
||||||
|
|
||||||
next = tmp->next;
|
g_hash_table_iter_init(&iter, channel->nicks);
|
||||||
if (!mask_match_address(channel->server, mask,
|
while (g_hash_table_iter_next(&iter, NULL, (void*)&nick)) {
|
||||||
nick->nick, nick->host))
|
for (; nick != NULL; nick = nick->next) {
|
||||||
nicks = g_slist_remove(nicks, tmp->data);
|
if (mask_match_address(channel->server, mask,
|
||||||
|
nick->nick, nick->host))
|
||||||
|
nicks = g_slist_prepend(nicks, nick);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nicks;
|
return nicks;
|
||||||
@ -264,8 +266,8 @@ NICK_REC *nicklist_find_mask(CHANNEL_REC *channel, const char *mask)
|
|||||||
static void get_nicks_hash(gpointer key, NICK_REC *rec, GSList **list)
|
static void get_nicks_hash(gpointer key, NICK_REC *rec, GSList **list)
|
||||||
{
|
{
|
||||||
while (rec != NULL) {
|
while (rec != NULL) {
|
||||||
*list = g_slist_append(*list, rec);
|
*list = g_slist_prepend(*list, rec);
|
||||||
rec = rec->next;
|
rec = rec->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user