aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-07-23 18:30:13 +0200
committerPřemysl Eric Janouch <p@janouch.name>2021-07-23 18:43:19 +0200
commitacddfe2cfab3692f21824d1345479b9c88367e30 (patch)
tree0fad5e8fd48e383bcf42235e283886d18eb35d50
parent051c43a072c4d75195ffaf42eb0375eba946994a (diff)
downloadxK-acddfe2cfab3692f21824d1345479b9c88367e30.tar.gz
xK-acddfe2cfab3692f21824d1345479b9c88367e30.tar.xz
xK-acddfe2cfab3692f21824d1345479b9c88367e30.zip
degesch: cleanup
-rw-r--r--degesch.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/degesch.c b/degesch.c
index fb3cee3..846d08f 100644
--- a/degesch.c
+++ b/degesch.c
@@ -7592,17 +7592,13 @@ channel_user_sort_entry_cmp (const void *entry_a, const void *entry_b)
static char *
make_channel_users_list (struct channel *channel)
{
- size_t n_users = 0;
- LIST_FOR_EACH (struct channel_user, iter, channel->users)
- n_users++;
-
- struct channel_user_sort_entry entries[n_users];
- size_t i = 0;
+ size_t n_users = channel->users_len;
+ struct channel_user_sort_entry entries[n_users], *p = entries;
LIST_FOR_EACH (struct channel_user, iter, channel->users)
{
- entries[i].s = channel->s;
- entries[i].channel_user = iter;
- i++;
+ p->s = channel->s;
+ p->channel_user = iter;
+ p++;
}
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
// and adding a new attribute seems like unnecessary work
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;
if (channel_user->user->away) str_append_c (&list, '\x1d');