Changeset 5c90890 for irc_user.c


Ignore:
Timestamp:
2018-07-12T08:54:12Z (6 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
c82e4ca
Parents:
b9d1fdc
git-author:
dequis <dx@…> (03-07-18 06:17:17)
git-committer:
dequis <dx@…> (12-07-18 08:54:12)
Message:

Stop using the irc->users linked list, use the hash table instead

irc_user_new() mentions that the reason this list is kept is for easy
iteration. Luckily, this is the future, and GHashTableIter exists now.

The main point of this is to get rid of the g_slist_insert_sorted() in
irc_user_set_nick() which is a particularly slow part of loading large
user lists, and scales poorly

In a test with discord, the GUILD_SYNC event is now 4 times faster, on
top of the improvements of the other bee_user hash tables patch.
Combining both patches it went from 136 to 6 seconds for 50k members.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_user.c

    rb9d1fdc r5c90890  
    3737        iu->key = g_strdup(nick);
    3838        nick_lc(irc, iu->key);
    39         /* Using the hash table for speed and irc->users for easy iteration
    40            through the list (since the GLib API doesn't have anything sane
    41            for that.) */
    4239        g_hash_table_insert(irc->nick_user_hash, iu->key, iu);
    43         irc->users = g_slist_insert_sorted(irc->users, iu, irc_user_cmp);
    4440
    4541        return iu;
     
    8783        irc_user_quit(iu, msg);
    8884
    89         irc->users = g_slist_remove(irc->users, iu);
    9085        g_hash_table_remove(irc->nick_user_hash, iu->key);
    9186
     
    148143        }
    149144
    150         irc->users = g_slist_remove(irc->users, iu);
    151145        g_hash_table_remove(irc->nick_user_hash, iu->key);
    152146
     
    175169        iu->key = g_strdup(key);
    176170        g_hash_table_insert(irc->nick_user_hash, iu->key, iu);
    177         irc->users = g_slist_insert_sorted(irc->users, iu, irc_user_cmp);
    178171
    179172        if (iu == irc->user) {
Note: See TracChangeset for help on using the changeset viewer.