Don't use Array#uniq in NodeSet#initialize.

Removing this makes the process of parsing larger XML documents a bit faster.
The downside is that NodeSet#initialize will no longer filter out duplicate
nodes, though this is not something Oga itself relies upon.

Methods such as NodeSet#push still do ignore elements already present.
This commit is contained in:
Yorick Peterse 2015-02-16 21:56:17 +01:00
parent c36b35ac0f
commit fdcd712ffe
2 changed files with 1 additions and 8 deletions

View File

@ -44,7 +44,7 @@ module Oga
# @param [Oga::XML::NodeSet] owner The owner of the set.
#
def initialize(nodes = [], owner = nil)
@nodes = nodes.uniq
@nodes = nodes
@owner = owner
@nodes.each { |node| take_ownership(node) } if owner

View File

@ -25,13 +25,6 @@ describe Oga::XML::NodeSet do
node.node_set.should == set
end
it 'only store unique nodes' do
n1 = Oga::XML::Element.new(:name => 'a')
set = described_class.new([n1, n1])
set.length.should == 1
end
end
describe '#each' do