[pypy-svn] r49350 - pypy/dist/pypy/rlib/parsing

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Dec 4 23:25:14 CET 2007


Author: cfbolz
Date: Tue Dec  4 23:25:12 2007
New Revision: 49350

Modified:
   pypy/dist/pypy/rlib/parsing/tree.py
Log:
prevent double dict lookup in the tree visitor dispatch


Modified: pypy/dist/pypy/rlib/parsing/tree.py
==============================================================================
--- pypy/dist/pypy/rlib/parsing/tree.py	(original)
+++ pypy/dist/pypy/rlib/parsing/tree.py	Tue Dec  4 23:25:12 2007
@@ -88,17 +88,19 @@
                            **dispatch_table):
     def dispatch(self, node):
         if isinstance(node, Nonterminal):
-            if node.symbol not in dispatch_table:
+            func = dispatch_table.get(node.symbol, None)
+            if func is None:
                 if __general_nonterminal_visit:
                     return __general_nonterminal_visit(self, node)
             else:
-                return dispatch_table[node.symbol](self, node)
+                return func(self, node)
         elif isinstance(node, Symbol):
-            if node.symbol not in dispatch_table:
+            func = dispatch_table.get(node.symbol, None)
+            if func is None:
                 if __general_symbol_visit:
                     return __general_symbol_visit(self, node)
             else:
-                return dispatch_table[node.symbol](self, node)
+                return func(self, node)
         if __general_visit:
             return __general_visit(self, node)
         raise VisitError(node)



More information about the Pypy-commit mailing list