Skip to content
Snippets Groups Projects
Commit f44fced2 authored by Nick Drozd's avatar Nick Drozd Committed by Claudiu Popa
Browse files

Move nodes_of_class null check out of inner loop

The check was being repeated unnecessarily in a tight loop.
parent 52e67656
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -627,8 +627,16 @@ class NodeNG(object):
"""
if isinstance(self, klass):
yield self
if skip_klass is None:
for child_node in self.get_children():
for matching in child_node.nodes_of_class(klass, skip_klass):
yield matching
return
for child_node in self.get_children():
if skip_klass is not None and isinstance(child_node, skip_klass):
if isinstance(child_node, skip_klass):
continue
for matching in child_node.nodes_of_class(klass, skip_klass):
yield matching
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment