Skip to content

Commit

Permalink
fixes `adopt_as' to relink the namespace of the new node
Browse files Browse the repository at this point in the history
previously `adopt_as' would call `relink_namespace' on the parent
node. this caused a loop such as the following

  1000.times {|i| root << root.create_element('randomNode') }

to run in O(n^2) instead of in linear time, since relink_namespace was
relinking the root node + 1 child node initially, then the root node + 2
nodes when the second node is added, etc.

fixes #692
  • Loading branch information
jvshahid committed Mar 11, 2016
1 parent 8cd92b2 commit 9caa43e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ext/java/nokogiri/XmlNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,7 @@ protected IRubyObject adoptAs(ThreadContext context, AdoptScheme scheme,
((XmlDocument) this).resetNamespaceCache(context);
}

relink_namespace(context);
other.relink_namespace(context);
// post_add_child(context, this, other);

return nodeOrTags;
Expand Down

0 comments on commit 9caa43e

Please sign in to comment.