Extract and reuse nodes creation code

This commit is contained in:
Dmitry-Me
2017-02-27 15:53:40 +03:00
parent 962732fd3e
commit 2aebfb7123
2 changed files with 24 additions and 33 deletions

View File

@@ -1819,8 +1819,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