Skip to content

Commit 7c17f05

Browse files
author
Robert Mosolgo
authored
Merge pull request #2504 from jhawthorn/skip_hooks
Skip visitor hooks entirely if possible
2 parents fc0b1f3 + 8ff637f commit 7c17f05

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/graphql/language/visitor.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ def on_abstract_node(node, parent)
9696
else
9797
# Run hooks if there are any
9898
new_node = node
99-
begin_hooks_ok = @visitors.empty? || begin_visit(new_node, parent)
100-
if begin_hooks_ok
99+
no_hooks = !@visitors.key?(node.class)
100+
if no_hooks || begin_visit(new_node, parent)
101101
node.children.each do |child_node|
102102
new_child_and_node = on_node_with_modifications(child_node, new_node)
103103
# Reassign `node` in case the child hook makes a modification
@@ -106,7 +106,7 @@ def on_abstract_node(node, parent)
106106
end
107107
end
108108
end
109-
@visitors.any? && end_visit(new_node, parent)
109+
end_visit(new_node, parent) unless no_hooks
110110

111111
if new_node.equal?(node)
112112
nil

0 commit comments

Comments
 (0)