diff options
author | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2010-07-22 07:59:11 +0000 |
---|---|---|
committer | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2010-07-22 07:59:11 +0000 |
commit | 546a0f756104fc9ae89207750c6a9eb566f5ea63 (patch) | |
tree | a0a7f4784c3876aee910790159947cf09ca960ac | |
parent | 93bb5dcb43a8f80044a12fab962ba546bcb5df6a (diff) |
xml_node::find_node is now not recursive
git-svn-id: http://pugixml.googlecode.com/svn/trunk@614 99668b35-9821-0410-8761-19e4c4f06640
-rw-r--r-- | src/pugixml.hpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/pugixml.hpp b/src/pugixml.hpp index 81f5769..6a5f7e4 100644 --- a/src/pugixml.hpp +++ b/src/pugixml.hpp @@ -1343,15 +1343,19 @@ namespace pugi { 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)) - return node; - - if (node.first_child()) + if (pred(cur)) return cur; + + if (cur.first_child()) cur = cur.first_child(); + else if (cur.next_sibling()) cur = cur.next_sibling(); + else { - xml_node found = node.find_node(pred); - if (found) return found; + while (!cur.next_sibling() && cur._root != _root) cur = cur.parent(); + + if (cur._root != _root) cur = cur.next_sibling(); } } |