mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Merge pull request #24 from ailin-nemui/speedup
Speed up nicklist and window_find operations
This commit is contained in:
commit
0331970d64
@ -2,7 +2,6 @@
|
||||
|
||||
#include "window-item-rec.h"
|
||||
|
||||
char *name;
|
||||
char *topic;
|
||||
char *topic_by;
|
||||
time_t topic_time;
|
||||
|
@ -281,40 +281,26 @@ GSList *nicklist_getnicks(CHANNEL_REC *channel)
|
||||
return list;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
CHANNEL_REC *channel;
|
||||
const char *nick;
|
||||
GSList *list;
|
||||
} NICKLIST_GET_SAME_REC;
|
||||
|
||||
static void get_nicks_same_hash(gpointer key, NICK_REC *nick,
|
||||
NICKLIST_GET_SAME_REC *rec)
|
||||
{
|
||||
while (nick != NULL) {
|
||||
if (g_ascii_strcasecmp(nick->nick, rec->nick) == 0) {
|
||||
rec->list = g_slist_append(rec->list, rec->channel);
|
||||
rec->list = g_slist_append(rec->list, nick);
|
||||
}
|
||||
|
||||
nick = nick->next;
|
||||
}
|
||||
}
|
||||
|
||||
GSList *nicklist_get_same(SERVER_REC *server, const char *nick)
|
||||
{
|
||||
NICKLIST_GET_SAME_REC rec;
|
||||
GSList *tmp;
|
||||
GSList *list = NULL;
|
||||
|
||||
g_return_val_if_fail(IS_SERVER(server), NULL);
|
||||
|
||||
rec.nick = nick;
|
||||
rec.list = NULL;
|
||||
for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
|
||||
rec.channel = tmp->data;
|
||||
g_hash_table_foreach(rec.channel->nicks,
|
||||
(GHFunc) get_nicks_same_hash, &rec);
|
||||
NICK_REC *nick_rec;
|
||||
CHANNEL_REC *channel = tmp->data;
|
||||
|
||||
for (nick_rec = g_hash_table_lookup(channel->nicks, nick);
|
||||
nick_rec != NULL;
|
||||
nick_rec = nick_rec->next) {
|
||||
list = g_slist_append(list, channel);
|
||||
list = g_slist_append(list, nick_rec);
|
||||
}
|
||||
}
|
||||
return rec.list;
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include "window-item-rec.h"
|
||||
|
||||
char *name;
|
||||
char *address;
|
||||
char *server_tag;
|
||||
time_t last_unread_msg;
|
||||
|
@ -7,7 +7,7 @@ GHashTable *module_data;
|
||||
void *window;
|
||||
STRUCT_SERVER_REC *server;
|
||||
char *visible_name;
|
||||
|
||||
char *name;
|
||||
time_t createtime;
|
||||
int data_level;
|
||||
char *hilight_color;
|
||||
|
@ -218,16 +218,10 @@ WI_ITEM_REC *window_item_find_window(WINDOW_REC *window,
|
||||
WI_ITEM_REC *rec = tmp->data;
|
||||
|
||||
if ((server == NULL || rec->server == server) &&
|
||||
g_ascii_strcasecmp(name, rec->visible_name) == 0)
|
||||
(g_ascii_strcasecmp(name, rec->visible_name) == 0
|
||||
|| (rec->name && g_ascii_strcasecmp(name, rec->name) == 0)))
|
||||
return rec;
|
||||
}
|
||||
|
||||
/* try with channel name too, it's not necessarily
|
||||
same as visible_name (!channels) */
|
||||
channel = channel_find(server, name);
|
||||
if (channel != NULL && window_item_window(channel) == window)
|
||||
return (WI_ITEM_REC *) channel;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user