* Parser/grammar1.c (finddfa): massive speed up by using direct

addressing instead of searching
This commit is contained in:
Guido van Rossum 1994-09-09 11:11:39 +00:00
parent 853474194f
commit 6522eb0400

View File

@ -36,8 +36,15 @@ finddfa(g, type)
grammar *g;
register int type;
{
register int i;
register dfa *d;
#if 1
/* Massive speed-up */
d = &g->g_dfa[type - NT_OFFSET];
assert(d->d_type == type);
return d;
#else
/* Old, slow version */
register int i;
for (i = g->g_ndfas, d = g->g_dfa; --i >= 0; d++) {
if (d->d_type == type)
@ -45,6 +52,7 @@ finddfa(g, type)
}
assert(0);
/* NOTREACHED */
#endif
}
char *