Merge branch 'master' into clone

This commit is contained in:
Lee Thomason
2017-06-14 15:10:37 -07:00
4 changed files with 130 additions and 15 deletions

View File

@@ -264,6 +264,13 @@ public:
return _allocated;
}
void SwapRemove(int i) {
TIXMLASSERT(i >= 0);
TIXMLASSERT(i < _size);
_mem[i] = _mem[_size - 1];
--_size;
}
const T* Mem() const {
TIXMLASSERT( _mem );
return _mem;
@@ -1826,6 +1833,9 @@ public:
// internal
char* Identify( char* p, XMLNode** node );
// internal
void MarkInUse(XMLNode*);
virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const {
return 0;
}
@@ -1846,6 +1856,13 @@ private:
int _errorLineNum;
char* _charBuffer;
int _parseCurLineNum;
// Memory tracking does add some overhead.
// However, the code assumes that you don't
// have a bunch of unlinked nodes around.
// Therefore it takes less memory to track
// in the document vs. a linked list in the XMLNode,
// and the performance is the same.
DynArray<XMLNode*, 10> _unlinked;
MemPoolT< sizeof(XMLElement) > _elementPool;
MemPoolT< sizeof(XMLAttribute) > _attributePool;
@@ -1868,6 +1885,8 @@ inline NodeType* XMLDocument::CreateUnlinkedNode( MemPoolT<PoolElementSize>& poo
NodeType* returnNode = new (pool.Alloc()) NodeType( this );
TIXMLASSERT( returnNode );
returnNode->_memPool = &pool;
_unlinked.Push(returnNode);
return returnNode;
}
@@ -2201,6 +2220,7 @@ public:
void ClearBuffer() {
_buffer.Clear();
_buffer.Push(0);
_firstElement = true;
}
protected: