Commit 6bf66ffd authored by Stefan Behnel's avatar Stefan Behnel

speed up NodeFinder

parent 0526d1b8
...@@ -550,10 +550,12 @@ class NodeFinder(TreeVisitor): ...@@ -550,10 +550,12 @@ class NodeFinder(TreeVisitor):
self.found = False self.found = False
def visit_Node(self, node): def visit_Node(self, node):
if node is self.node: if self.found:
pass # short-circuit
elif node is self.node:
self.found = True self.found = True
else: else:
self.visitchildren(node) self._visitchildren(node, None)
def tree_contains(tree, node): def tree_contains(tree, node):
finder = NodeFinder(node) finder = NodeFinder(node)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment