Merge pull request #527 from Dmitry-Me/reuseNodesCreationCode

Extract and reuse nodes creation code
This commit is contained in:
Lee Thomason
2017-03-01 13:15:52 -08:00
committed by GitHub
2 changed files with 24 additions and 33 deletions

View File

@@ -1830,8 +1830,21 @@ private:
static const char* _errorNames[XML_ERROR_COUNT];
void Parse();
template<class NodeType, int PoolElementSize>
NodeType* CreateUnlinkedNode( MemPoolT<PoolElementSize>& pool );
};
template<class NodeType, int PoolElementSize>
inline NodeType* XMLDocument::CreateUnlinkedNode( MemPoolT<PoolElementSize>& pool )
{
TIXMLASSERT( sizeof( NodeType ) == PoolElementSize );
TIXMLASSERT( sizeof( NodeType ) == pool.ItemSize() );
NodeType* returnNode = new (pool.Alloc()) NodeType( this );
TIXMLASSERT( returnNode );
returnNode->_memPool = &pool;
return returnNode;
}
/**
A XMLHandle is a class that wraps a node pointer with null checks; this is