From: michael Date: Tue, 2 Jun 2015 16:39:41 +0000 (+0000) Subject: - scan.c:scan_irckline(): avoid table indexing where possible X-Git-Tag: 1.0.7~18 X-Git-Url: http://git.serene-ircd.net/?a=commitdiff_plain;h=0056caec4221d16fb3d0082948868dcb046df695;p=hopm.git - scan.c:scan_irckline(): avoid table indexing where possible git-svn-id: svn://svn.ircd-hybrid.org/svnroot/hopm/branches/1.0.x@6027 82007160-df01-0410-b94d-b575c5fd34c7 --- diff --git a/src/scan.c b/src/scan.c index 5907377..4d90c1a 100644 --- a/src/scan.c +++ b/src/scan.c @@ -774,7 +774,6 @@ scan_irckline(const struct scan_struct *ss, const char *format, const char *type unsigned int pos = 0; /* position in format */ unsigned int len = 0; /* position in message */ unsigned int size = 0; /* temporary size buffer */ - unsigned int i; struct kline_format_assoc { const char key; @@ -816,18 +815,18 @@ scan_irckline(const struct scan_struct *ss, const char *format, const char *type } /* Safe to check against table now */ - for (i = 0; i < (sizeof(table) / sizeof(struct kline_format_assoc)); ++i) + for (const struct kline_format_assoc *tab = table; tab->key; ++tab) { - if (table[i].key == format[pos + 1]) + if (tab->key == format[pos + 1]) { - size = strlen(table[i].data); + size = strlen(tab->data); /* Check if the new string can fit! */ if ((size + len) > (MSGLENMAX - 1)) break; else { - strlcat(message, table[i].data, sizeof(message)); + strlcat(message, tab->data, sizeof(message)); len += size; } }