commit b3477280fbd5d5ca483d13ff771be76d98ca2b49
parent dd9d39f1f5a09924ab111b97e64d144075d898cd
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sun, 9 Mar 2014 20:29:16 +0100
Optimize lookup()
Diffstat:
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/symbol.c b/symbol.c
@@ -66,8 +66,8 @@ struct symbol *
lookup(register const char *s, signed char ns)
{
register struct symbol *sym;
- static unsigned char key, l;
-
+ static unsigned char key;
+ register char *t;
if (s == NULL) {
sym = xcalloc(1, sizeof(*sym));
@@ -75,11 +75,10 @@ lookup(register const char *s, signed char ns)
return sym;
}
- l = strlen(s);
key = hash(s) & NR_SYM_HASH - 1;
-
for (sym = htab[key]; sym; sym = sym->hash) {
- if (ns == sym->ns && !memcmp(sym->name, s, l))
+ t = sym->name;
+ if (ns == sym->ns && *t == *s && !strcmp(t, s))
return sym;
}