Skip to content

Commit fc0b1f3

Browse files
author
Robert Mosolgo
authored
Merge pull request #2498 from tenderlove/fewer-imemo
Reduce allocations in `apply_hooks`
2 parents 94bbd55 + 6e7bee9 commit fc0b1f3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/graphql/language/visitor.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,10 @@ def end_visit(node, parent)
211211

212212
# If one of the visitors returns SKIP, stop visiting this node
213213
def self.apply_hooks(hooks, node, parent)
214-
hooks.reduce(true) { |memo, proc| memo && (proc.call(node, parent) != SKIP) }
214+
hooks.each do |proc|
215+
return false if proc.call(node, parent) == SKIP
216+
end
217+
true
215218
end
216219

217220
# Collect `enter` and `leave` hooks for classes in {GraphQL::Language::Nodes}

0 commit comments

Comments
 (0)