From ad99e73a60408e8fe6eb505c95b06ebb580909a2 Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Fri, 7 Oct 2016 10:43:34 +0200 Subject: [PATCH] increased default XML name pool size, added Document constructor taking name pool size as argument --- XML/include/Poco/DOM/Document.h | 10 +++++++++- XML/include/Poco/XML/NamePool.h | 7 ++++++- XML/src/Document.cpp | 23 +++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/XML/include/Poco/DOM/Document.h b/XML/include/Poco/DOM/Document.h index 407b372bf..6cdbaa1e1 100644 --- a/XML/include/Poco/DOM/Document.h +++ b/XML/include/Poco/DOM/Document.h @@ -62,11 +62,15 @@ class XML_API Document: public AbstractContainerNode, public DocumentEvent public: typedef Poco::AutoReleasePool 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 @@ -74,6 +78,10 @@ public: /// 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. diff --git a/XML/include/Poco/XML/NamePool.h b/XML/include/Poco/XML/NamePool.h index e7c976cfc..7ff81ca5d 100644 --- a/XML/include/Poco/XML/NamePool.h +++ b/XML/include/Poco/XML/NamePool.h @@ -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 { @@ -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); diff --git a/XML/src/Document.cpp b/XML/src/Document.cpp index 7bf6182eb..604722ae8 100644 --- a/XML/src/Document.cpp +++ b/XML/src/Document.cpp @@ -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), @@ -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();