From: michael Date: Tue, 2 Jun 2015 16:22:21 +0000 (+0000) Subject: - stats.c: avoid table indexing where possible X-Git-Tag: 1.0.7~20 X-Git-Url: http://git.serene-ircd.net/?a=commitdiff_plain;h=ef83468e72f2dcdaaa327ef1d81baa7451305d5b;p=hopm.git - stats.c: avoid table indexing where possible git-svn-id: svn://svn.ircd-hybrid.org/svnroot/hopm/branches/1.0.x@6023 82007160-df01-0410-b94d-b575c5fd34c7 --- diff --git a/src/stats.c b/src/stats.c index 1ad95bb..977d7fd 100644 --- a/src/stats.c +++ b/src/stats.c @@ -53,7 +53,8 @@ static struct StatsHash STATS_PROXIES[] = { OPM_TYPE_SOCKS5, 0, "SOCKS5" }, { OPM_TYPE_ROUTER, 0, "ROUTER" }, { OPM_TYPE_WINGATE, 0, "WINGATE" }, - { OPM_TYPE_DREAMBOX, 0, "DREAMBOX" } + { OPM_TYPE_DREAMBOX, 0, "DREAMBOX" }, + { 0, 0, NULL } }; @@ -83,11 +84,11 @@ stats_init(void) void stats_openproxy(int type) { - for (unsigned int i = 0; i < (sizeof(STATS_PROXIES) / sizeof(struct StatsHash)); ++i) + for (struct StatsHash *tab = STATS_PROXIES; tab->name; ++tab) { - if (STATS_PROXIES[i].type == type) + if (tab->type == type) { - ++STATS_PROXIES[i].count; + ++tab->count; break; } } @@ -170,10 +171,10 @@ stats_output(const char *target) irc_send("PRIVMSG %s :DNSBL: %u reports sent", target, STATS_DNSBLSENT); - for (unsigned int i = 0; i < (sizeof(STATS_PROXIES) / sizeof(struct StatsHash)); ++i) - if (STATS_PROXIES[i].count > 0) + for (const struct StatsHash *tab = STATS_PROXIES; tab->name; ++tab) + if (tab->count) irc_send("PRIVMSG %s :Found %u (%s) open.", target, - STATS_PROXIES[i].count, STATS_PROXIES[i].name); + tab->count, tab->name); irc_send("PRIVMSG %s :Number of connects: %u (%.2f/minute)", target, STATS_CONNECTIONS, STATS_CONNECTIONS ?