mirror of
https://github.com/python/cpython.git
synced 2024-11-24 18:34:43 +08:00
* Parser/grammar1.c (finddfa): massive speed up by using direct
addressing instead of searching
This commit is contained in:
parent
853474194f
commit
6522eb0400
@ -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 *
|
||||
|
Loading…
Reference in New Issue
Block a user