degesch: cleanup

This commit is contained in:
Přemysl Eric Janouch 2021-07-23 18:30:13 +02:00
parent 051c43a072
commit acddfe2cfa
Signed by: p
GPG Key ID: A0420B94F92B9493

View File

@ -7592,17 +7592,13 @@ channel_user_sort_entry_cmp (const void *entry_a, const void *entry_b)
static char * static char *
make_channel_users_list (struct channel *channel) make_channel_users_list (struct channel *channel)
{ {
size_t n_users = 0; size_t n_users = channel->users_len;
LIST_FOR_EACH (struct channel_user, iter, channel->users) struct channel_user_sort_entry entries[n_users], *p = entries;
n_users++;
struct channel_user_sort_entry entries[n_users];
size_t i = 0;
LIST_FOR_EACH (struct channel_user, iter, channel->users) LIST_FOR_EACH (struct channel_user, iter, channel->users)
{ {
entries[i].s = channel->s; p->s = channel->s;
entries[i].channel_user = iter; p->channel_user = iter;
i++; p++;
} }
qsort (entries, n_users, sizeof *entries, channel_user_sort_entry_cmp); qsort (entries, n_users, sizeof *entries, channel_user_sort_entry_cmp);
@ -7610,7 +7606,7 @@ make_channel_users_list (struct channel *channel)
// Make names of users that are away italicised, constructing a formatter // Make names of users that are away italicised, constructing a formatter
// and adding a new attribute seems like unnecessary work // and adding a new attribute seems like unnecessary work
struct str list = str_make (); struct str list = str_make ();
for (i = 0; i < n_users; i++) for (size_t i = 0; i < n_users; i++)
{ {
struct channel_user *channel_user = entries[i].channel_user; struct channel_user *channel_user = entries[i].channel_user;
if (channel_user->user->away) str_append_c (&list, '\x1d'); if (channel_user->user->away) str_append_c (&list, '\x1d');