ref: e11576874bba09ca8d7e52be405c9c29518b49bd
parent: 1c450f351d049e620d63b4dd9ad7acc0bc6f0ed3
author: Roberto E. Vargas Caballero <[email protected]>
date: Sun Mar 9 12:03:56 EDT 2014
Optimize the search of keywords It is difficult two strings with the same hash and the same initial letter, so this test save a lot of calls to strcmp.
--- a/lex.c
+++ b/lex.c
@@ -170,12 +170,12 @@
}
static unsigned char
-keyword(char *s)
+keyword(register char *s)
{
register struct keyword *bp;
for (bp = ktab[hash(s) & NR_KEYW_HASH-1]; bp; bp = bp->next) {
- if (!strcmp(bp->str, s))
+ if (*s == *bp->str && !strcmp(bp->str, s))
return bp->tok;
}
return 0;