]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
* Parser/grammar1.c (finddfa): massive speed up by using direct
authorGuido van Rossum <guido@python.org>
Fri, 9 Sep 1994 11:11:39 +0000 (11:11 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 9 Sep 1994 11:11:39 +0000 (11:11 +0000)
addressing instead of searching

Parser/grammar1.c

index 612f4912f2cb21bd37908418490b555cc5ff3a95..ee8933f0b361581c8844dc910f620dd5b059ed83 100644 (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 *