ref: 569af2fa5e0dfaa663e64f852fc50ecddb885af3
parent: 6030d9c7298661721d0490c0ebf15e0b3aa5181e
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Sep 28 04:48:19 EDT 2017
[as] Don't use casecmp with bsearch() We can convert to upper case the verb before begin to compare. It will make faster all the comparisions that is where the time will be consumed.
--- a/as/main.c
+++ b/as/main.c
@@ -15,19 +15,23 @@
const char *s = f1;
int d;
- d = toupper(*ins->str) - toupper(*s);
- if (d != 0)
+ if ((d = *s - *ins->str) != 0)
return d;
- return casecmp(s, ins->str);
+ return strcmp(s, ins->str);
}
static void
as(char *text, char *xargs)
{
+ int c;
+ char *p;
Ins *ins;
Op *op, *lim;
Node **args;
+
+ for (p = text; c = *p; ++p)
+ *p = toupper(c);
ins = bsearch(text, instab, nr_ins, sizeof(Ins), cmp);
if (!ins) {