0
0
mirror of https://github.com/zeux/pugixml.git synced 2024-12-27 13:33:17 +08:00

Use raw pointers in xml_node::traverse implementation

This makes it a bit faster and matches other internal code better.
This commit is contained in:
Arseny Kapoulkine 2017-11-13 19:29:42 -08:00
parent 344c74a74c
commit 257fbb4e1b

View File

@ -6202,10 +6202,10 @@ namespace pugi
{ {
walker._depth = -1; walker._depth = -1;
xml_node arg_begin = *this; xml_node arg_begin(_root);
if (!walker.begin(arg_begin)) return false; if (!walker.begin(arg_begin)) return false;
xml_node cur = first_child(); xml_node_struct* cur = _root ? _root->first_child + 0 : 0;
if (cur) if (cur)
{ {
@ -6213,36 +6213,35 @@ namespace pugi
do do
{ {
xml_node arg_for_each = cur; xml_node arg_for_each(cur);
if (!walker.for_each(arg_for_each)) if (!walker.for_each(arg_for_each))
return false; return false;
if (cur.first_child()) if (cur->first_child)
{ {
++walker._depth; ++walker._depth;
cur = cur.first_child(); cur = cur->first_child;
} }
else if (cur.next_sibling()) else if (cur->next_sibling)
cur = cur.next_sibling(); cur = cur->next_sibling;
else else
{ {
// Borland C++ workaround while (!cur->next_sibling && cur != _root && cur->parent)
while (!cur.next_sibling() && cur != *this && !cur.parent().empty())
{ {
--walker._depth; --walker._depth;
cur = cur.parent(); cur = cur->parent;
} }
if (cur != *this) if (cur != _root)
cur = cur.next_sibling(); cur = cur->next_sibling;
} }
} }
while (cur && cur != *this); while (cur && cur != _root);
} }
assert(walker._depth == -1); assert(walker._depth == -1);
xml_node arg_end = *this; xml_node arg_end(_root);
return walker.end(arg_end); return walker.end(arg_end);
} }