diff options
author | Alexander Færøy <ahf@0x90.dk> | 2014-06-16 00:27:07 +0200 |
---|---|---|
committer | Alexander Færøy <ahf@0x90.dk> | 2014-06-16 00:27:07 +0200 |
commit | 0331970d64db01bd2db0d86a253393938b2539f1 (patch) | |
tree | 51e72be3c00ca90e503e7f6e3ec3da84f96280ab /src/core | |
parent | d1e60a3b8f8a154a33e935279a6aeb356686efda (diff) | |
parent | a8c52d8c1619e97a9f9a49ddc9c2c6a242cbb0ce (diff) | |
download | irssi-0331970d64db01bd2db0d86a253393938b2539f1.zip |
Merge pull request #24 from ailin-nemui/speedup
Speed up nicklist and window_find operations
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/channel-rec.h | 1 | ||||
-rw-r--r-- | src/core/nicklist.c | 38 | ||||
-rw-r--r-- | src/core/query-rec.h | 1 | ||||
-rw-r--r-- | src/core/window-item-rec.h | 2 |
4 files changed, 13 insertions, 29 deletions
diff --git a/src/core/channel-rec.h b/src/core/channel-rec.h index 7b806ca4..f3ec5f8d 100644 --- a/src/core/channel-rec.h +++ b/src/core/channel-rec.h @@ -2,7 +2,6 @@ #include "window-item-rec.h" -char *name; char *topic; char *topic_by; time_t topic_time; diff --git a/src/core/nicklist.c b/src/core/nicklist.c index d6590261..a5f25f34 100644 --- a/src/core/nicklist.c +++ b/src/core/nicklist.c @@ -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 { diff --git a/src/core/query-rec.h b/src/core/query-rec.h index ddb85ba4..fc08d2ef 100644 --- a/src/core/query-rec.h +++ b/src/core/query-rec.h @@ -2,7 +2,6 @@ #include "window-item-rec.h" -char *name; char *address; char *server_tag; time_t last_unread_msg; diff --git a/src/core/window-item-rec.h b/src/core/window-item-rec.h index d7b6f7db..7bf5ba5f 100644 --- a/src/core/window-item-rec.h +++ b/src/core/window-item-rec.h @@ -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; |