xml_node::find_node is now not recursive

git-svn-id: http://pugixml.googlecode.com/svn/trunk@614 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
arseny.kapoulkine 2010-07-22 07:59:11 +00:00
parent 93bb5dcb43
commit 546a0f7561

View File

@ -1343,15 +1343,19 @@ namespace pugi
{ {
if (!_root) return xml_node(); if (!_root) return xml_node();
for (xml_node node = first_child(); node; node = node.next_sibling()) xml_node cur = first_child();
while (cur._root && cur._root != _root)
{ {
if (pred(node)) if (pred(cur)) return cur;
return node;
if (cur.first_child()) cur = cur.first_child();
if (node.first_child()) else if (cur.next_sibling()) cur = cur.next_sibling();
else
{ {
xml_node found = node.find_node(pred); while (!cur.next_sibling() && cur._root != _root) cur = cur.parent();
if (found) return found;
if (cur._root != _root) cur = cur.next_sibling();
} }
} }