mirror of
https://github.com/irssi/irssi.git
synced 2024-11-03 04:27:19 -05:00
improve nicklist performance
This commit is contained in:
parent
689e80c087
commit
787e192567
@ -166,41 +166,50 @@ void nicklist_rename_unique(SERVER_REC *server,
|
|||||||
nicklist_get_same_unique(server, old_nick_id));
|
nicklist_get_same_unique(server, old_nick_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define NICKLIST_GETNICKS_LOOP_INIT(hashtable) \
|
||||||
|
do { \
|
||||||
|
GHashTableIter _iter; \
|
||||||
|
g_hash_table_iter_init(&_iter, (hashtable)); \
|
||||||
|
while (g_hash_table_iter_next(&_iter, NULL, (void*)&nick)) { \
|
||||||
|
while (nick != NULL) {
|
||||||
|
#define NICKLIST_GETNICKS_LOOP_END \
|
||||||
|
nick = nick->next; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
nicks = nicklist_getnicks(channel);
|
NICKLIST_GETNICKS_LOOP_INIT(channel->nicks);
|
||||||
nick = NULL;
|
|
||||||
for (tmp = nicks; tmp != NULL; tmp = tmp->next) {
|
|
||||||
nick = tmp->data;
|
|
||||||
|
|
||||||
if (mask_match_address(channel->server, mask,
|
if (mask_match_address(channel->server, mask,
|
||||||
nick->nick, nick->host))
|
nick->nick, nick->host))
|
||||||
break;
|
return nick;
|
||||||
}
|
|
||||||
g_slist_free(nicks);
|
NICKLIST_GETNICKS_LOOP_END;
|
||||||
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;
|
||||||
|
|
||||||
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;
|
NICKLIST_GETNICKS_LOOP_INIT(channel->nicks);
|
||||||
if (!mask_match_address(channel->server, mask,
|
|
||||||
nick->nick, nick->host))
|
if (mask_match_address(channel->server, mask,
|
||||||
nicks = g_slist_remove(nicks, tmp->data);
|
nick->nick, nick->host))
|
||||||
}
|
nicks = g_slist_prepend(nicks, nick);
|
||||||
|
|
||||||
|
NICKLIST_GETNICKS_LOOP_END;
|
||||||
|
|
||||||
return nicks;
|
return nicks;
|
||||||
}
|
}
|
||||||
@ -264,8 +273,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