Optimize descendant-or-self and child axes.
By using NodeSet#concat we can further reduce the amount of object allocations. This in turn greatly reduces the time it takes to query large documents using descendant-or-self.
This commit is contained in:
parent
9f6035e784
commit
ef03a12f99
|
@ -338,8 +338,11 @@ module Oga
|
|||
# @return [Oga::XML::NodeSet]
|
||||
#
|
||||
def on_axis_descendant_or_self(ast_node, context)
|
||||
return on_test(ast_node, context) +
|
||||
on_axis_descendant(ast_node, context)
|
||||
nodes = on_test(ast_node, context)
|
||||
|
||||
nodes.concat(on_axis_descendant(ast_node, context))
|
||||
|
||||
return nodes
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -1585,7 +1588,7 @@ module Oga
|
|||
children = XML::NodeSet.new
|
||||
|
||||
nodes.each do |xml_node|
|
||||
children += xml_node.children
|
||||
children.concat(xml_node.children)
|
||||
end
|
||||
|
||||
return children
|
||||
|
|
Loading…
Reference in New Issue