- scan.c:scan_irckline(): avoid table indexing where possible
authormichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>
Tue, 2 Jun 2015 16:39:41 +0000 (16:39 +0000)
committermichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>
Tue, 2 Jun 2015 16:39:41 +0000 (16:39 +0000)
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/hopm/branches/1.0.x@6027 82007160-df01-0410-b94d-b575c5fd34c7

src/scan.c

index 5907377b247c06e4ad61f76e200069b67b91ea99..4d90c1a1134030e930b81ff1f268bea594272b97 100644 (file)
@@ -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;
             }
           }