1
0
mirror of https://github.com/leethomason/tinyxml2.git synced 2026-07-21 19:23:00 +04:00

Improved XMLNode::~XMLNode perfomance (#1075)

Improved XMLNode::~XMLNode perfomance (#1075)
This commit is contained in:
Lee Thomason
2026-05-23 16:13:32 -07:00
committed by GitHub
parent 3dcad8e3c3
commit 8d8472fe1a
2 changed files with 11 additions and 9 deletions
+11 -1
View File
@@ -834,7 +834,17 @@ XMLNode::XMLNode( XMLDocument* doc ) :
XMLNode::~XMLNode()
{
DeleteChildren();
// Fast path: this node is dying, so maintaining _firstChild/_lastChild and
// sibling _prev/_next links is unnecessary. Only _parent must be zeroed to
// satisfy the MarkInUse assertion inside DeleteNode.
XMLNode *currentChild = _firstChild;
while (currentChild != NULL) {
XMLNode *next = currentChild->_next;
currentChild->_parent = 0;
DeleteNode(currentChild);
currentChild = next;
}
if ( _parent ) {
_parent->Unlink( this );
}