Reduce object allocations in on_axis_descendant

By using Traversal#each_node and _not_ calling on_test() (which was only called
for node_matches?) we can save ourselves a few object allocations.
This commit is contained in:
Yorick Peterse 2014-09-05 19:58:37 +02:00
parent 98984de540
commit 9f6035e784
1 changed files with 7 additions and 2 deletions

View File

@ -318,8 +318,13 @@ module Oga
nodes = XML::NodeSet.new
context.each do |context_node|
nodes.concat(on_test(ast_node, context_node.children))
nodes.concat(on_axis_descendant(ast_node, context_node.children))
context_node.children.each do |node|
nodes << node if node_matches?(node, ast_node)
end
context_node.each_node do |node|
nodes << node if node_matches?(node, ast_node)
end
end
return nodes