diff options
author | Guido van Rossum <guido@python.org> | 1994-09-09 11:11:39 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1994-09-09 11:11:39 (GMT) |
commit | 6522eb0400ef5aef9d74d371638ec8b6757e1f39 (patch) | |
tree | d26870678c74e9688fc28c616a9e9ecc3e061266 | |
parent | 853474194fa799ab96a135f900332eaca52a07e7 (diff) | |
download | cpython-6522eb0400ef5aef9d74d371638ec8b6757e1f39.zip cpython-6522eb0400ef5aef9d74d371638ec8b6757e1f39.tar.gz cpython-6522eb0400ef5aef9d74d371638ec8b6757e1f39.tar.bz2 |
* Parser/grammar1.c (finddfa): massive speed up by using direct
addressing instead of searching
-rw-r--r-- | Parser/grammar1.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Parser/grammar1.c b/Parser/grammar1.c index 612f491..ee8933f 100644 --- a/Parser/grammar1.c +++ b/Parser/grammar1.c @@ -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 * |