Skip to content

Commit

Permalink
increased default XML name pool size, added Document constructor taki…
Browse files Browse the repository at this point in the history
…ng name pool size as argument
  • Loading branch information
obiltschnig committed Oct 7, 2016
1 parent d9c3c52 commit 2817376
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
10 changes: 9 additions & 1 deletion XML/include/Poco/DOM/Document.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,26 @@ class XML_API Document: public AbstractContainerNode, public DocumentEvent
public:
typedef Poco::AutoReleasePool<DOMObject> AutoReleasePool;

Document(NamePool* pNamePool = 0);
explicit Document(NamePool* pNamePool = 0);
/// Creates a new document. If pNamePool == 0, the document
/// creates its own name pool, otherwise it uses the given name pool.
/// Sharing a name pool makes sense for documents containing instances
/// of the same schema, thus reducing memory usage.

explicit Document(unsigned long namePoolSize);
/// Creates a new document using a name pool with the given size, which
/// should be a prime number (e.g., 251, 509, 1021, 4093).

Document(DocumentType* pDocumentType, NamePool* pNamePool = 0);
/// Creates a new document. If pNamePool == 0, the document
/// creates its own name pool, otherwise it uses the given name pool.
/// Sharing a name pool makes sense for documents containing instances
/// of the same schema, thus reducing memory usage.

Document(DocumentType* pDocumentType, unsigned long namePoolSize);
/// Creates a new document using a name pool with the given size, which
/// should be a prime number (e.g., 251, 509, 1021, 4093).

NamePool& namePool();
/// Returns a pointer to the documents Name Pool.

Expand Down
7 changes: 6 additions & 1 deletion XML/include/Poco/XML/NamePool.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
#include "Poco/XML/Name.h"


#ifndef POCO_XML_NAMEPOOL_DEFAULT_SIZE
#define POCO_XML_NAMEPOOL_DEFAULT_SIZE 509
#endif


namespace Poco {
namespace XML {

Expand All @@ -37,7 +42,7 @@ class XML_API NamePool
/// local name and a qualified name.
{
public:
NamePool(unsigned long size = 251);
NamePool(unsigned long size = POCO_XML_NAMEPOOL_DEFAULT_SIZE);
/// Creates a name pool with room for up to size strings.

const Name& insert(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName);
Expand Down
23 changes: 23 additions & 0 deletions XML/src/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ Document::Document(NamePool* pNamePool):
}


Document::Document(unsigned long namePoolSize):
AbstractContainerNode(0),
_pDocumentType(0),
_pNamePool(new NamePool(namePoolSize)),
_eventSuspendLevel(0)
{
}


Document::Document(DocumentType* pDocumentType, NamePool* pNamePool):
AbstractContainerNode(0),
_pDocumentType(pDocumentType),
Expand All @@ -79,6 +88,20 @@ Document::Document(DocumentType* pDocumentType, NamePool* pNamePool):
}


Document::Document(DocumentType* pDocumentType, unsigned long namePoolSize):
AbstractContainerNode(0),
_pDocumentType(pDocumentType),
_pNamePool(new NamePool(namePoolSize)),
_eventSuspendLevel(0)
{
if (_pDocumentType)
{
_pDocumentType->duplicate();
_pDocumentType->setOwnerDocument(this);
}
}


Document::~Document()
{
if (_pDocumentType) _pDocumentType->release();
Expand Down

0 comments on commit 2817376

Please sign in to comment.