diff --git a/src/xercesc/dom/impl/DOMAttrImpl.cpp b/src/xercesc/dom/impl/DOMAttrImpl.cpp index e91a37bb0b4340a38f7ce9f12f15718c149c5a42..bef164d83e677b704741413212dc2a95a8203d3d 100644 --- a/src/xercesc/dom/impl/DOMAttrImpl.cpp +++ b/src/xercesc/dom/impl/DOMAttrImpl.cpp @@ -186,7 +186,7 @@ void DOMAttrImpl::setValue(const XMLCh *val) } if (val != 0) // Create and add the new one - appendChild(doc->createTextNode(val)); + fParent.appendChildFast(doc->createTextNode(val)); fNode.isSpecified(true); fParent.changed(); diff --git a/src/xercesc/dom/impl/DOMAttrMapImpl.cpp b/src/xercesc/dom/impl/DOMAttrMapImpl.cpp index bd2149ee23403039c80484b7e930a4cb6913b03a..1a06594f99d6ab54a85844244e317db00c32ef0e 100644 --- a/src/xercesc/dom/impl/DOMAttrMapImpl.cpp +++ b/src/xercesc/dom/impl/DOMAttrMapImpl.cpp @@ -68,7 +68,7 @@ void DOMAttrMapImpl::cloneContent(const DOMAttrMapImpl *srcmap) { unsigned int size = srcmap->fNodes->size(); if(size > 0) { - DOMDocument *doc = fOwnerNode->getOwnerDocument(); + DOMDocumentImpl *doc = (DOMDocumentImpl*)fOwnerNode->getOwnerDocument(); fNodes = new (doc) DOMNodeVector(doc, size); } } @@ -185,7 +185,7 @@ DOMNode *DOMAttrMapImpl::setNamedItem(DOMNode *arg) i=-1-i; // Insert point (may be end of list) if(0==fNodes) { - fNodes=new (doc) DOMNodeVector(doc); + fNodes=new ((DOMDocumentImpl*)doc) DOMNodeVector(doc); } fNodes->insertElementAt(arg,i); } @@ -261,7 +261,7 @@ DOMNode *DOMAttrMapImpl::setNamedItemNS(DOMNode* arg) if (i<0) i = -1 - i; if(0==fNodes) - fNodes=new (doc) DOMNodeVector(doc); + fNodes=new ((DOMDocumentImpl*)doc) DOMNodeVector(doc); fNodes->insertElementAt(arg,i); } if (previous != 0) { diff --git a/src/xercesc/dom/impl/DOMDocumentImpl.cpp b/src/xercesc/dom/impl/DOMDocumentImpl.cpp index 3719250eb691d26be06c155cbe0df2a491966d0a..c83134b2f52ad3a4c915c5c46255e69a289782fd 100644 --- a/src/xercesc/dom/impl/DOMDocumentImpl.cpp +++ b/src/xercesc/dom/impl/DOMDocumentImpl.cpp @@ -541,7 +541,8 @@ DOMNode* DOMDocumentImpl::replaceChild(DOMNode *newChild, DOMNode *oldChild) { bool DOMDocumentImpl::isXMLName(const XMLCh *s) { - if (XMLString::equals(fXmlVersion, XMLUni::fgVersion1_1)) + // fXmlVersion points directly to the static constants + if (fXmlVersion==XMLUni::fgVersion1_1) return XMLChar1_1::isValidName(s); else return XMLChar1_0::isValidName(s); @@ -966,12 +967,18 @@ const XMLCh* DOMDocumentImpl::getXmlVersion() const { } void DOMDocumentImpl::setXmlVersion(const XMLCh* version){ - if ((version && *version) && - !XMLString::equals(version, XMLUni::fgVersion1_0) && - !XMLString::equals(version, XMLUni::fgVersion1_1)) - throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0, getMemoryManager()); - fXmlVersion = cloneString(version); + // store the static strings, so that comparisons will be faster + if(version==0) + fXmlVersion = 0; + else if(*version==0) + fXmlVersion = XMLUni::fgZeroLenString; + else if(XMLString::equals(version, XMLUni::fgVersion1_0)) + fXmlVersion = XMLUni::fgVersion1_0; + else if(XMLString::equals(version, XMLUni::fgVersion1_1)) + fXmlVersion = XMLUni::fgVersion1_1; + else + throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0, getMemoryManager()); } const XMLCh* DOMDocumentImpl::getDocumentURI() const diff --git a/src/xercesc/util/PlatformUtils.hpp b/src/xercesc/util/PlatformUtils.hpp index c3c3d3effc0d63ac80116631f2154a2bf49c4428..973727c93ede8849b4c9d25520aa3bd679bd4f5e 100644 --- a/src/xercesc/util/PlatformUtils.hpp +++ b/src/xercesc/util/PlatformUtils.hpp @@ -121,23 +121,13 @@ public : */ static MemoryManager* fgMemoryManager; - /** The array-allocating memory manager - * - * This memory manager always allocates memory by calling the - * global new[] operator. It may be used to allocate memory - * where such memory needs to be deletable by calling delete []. - * Since this allocator is always guaranteed to do the same thing - * there is no reason, nor facility, to override it. - */ - static MemoryManager* fgArrayMemoryManager; - - static XMLFileMgr* fgFileMgr; - static XMLMutexMgr* fgMutexMgr; - static XMLAtomicOpMgr* fgAtomicOpMgr; + static XMLFileMgr* fgFileMgr; + static XMLMutexMgr* fgMutexMgr; + static XMLAtomicOpMgr* fgAtomicOpMgr; - static XMLMutex* fgAtomicMutex; + static XMLMutex* fgAtomicMutex; - static bool fgXMLChBigEndian; + static bool fgXMLChBigEndian; //@} @@ -219,9 +209,8 @@ public : * * @param manager The MemoryManager to use to allocate objects */ - static XMLFileMgr* - makeFileMgr(MemoryManager* const manager); - + static XMLFileMgr* makeFileMgr(MemoryManager* const manager); + /** Get the current file position * * This must be implemented by the per-platform driver, which should @@ -347,7 +336,7 @@ public : static XMLSize_t readFileBuffer ( FileHandle theFile - , const XMLSize_t toRead + , const XMLSize_t toRead , XMLByte* const toFill , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); @@ -541,7 +530,7 @@ public : * * @param manager The MemoryManager to use to allocate objects */ - static XMLMutexMgr* makeMutexMgr(MemoryManager* const manager); + static XMLMutexMgr* makeMutexMgr(MemoryManager* const manager); /** Closes a mutex handle * @@ -614,7 +603,7 @@ public : * * @param manager The MemoryManager to use to allocate objects */ - static XMLAtomicOpMgr* makeAtomicOpMgr(MemoryManager* const manager); + static XMLAtomicOpMgr* makeAtomicOpMgr(MemoryManager* const manager); /** Conditionally updates or returns a single word variable atomically @@ -701,7 +690,7 @@ public : /** @name NEL Character Handling */ //@{ - /** + /** * This function enables the recognition of NEL(0x85) char and LSEP (0x2028) as newline chars * which is disabled by default. * It is only called once per process. Once it is set, any subsequent calls @@ -723,7 +712,7 @@ public : /** @name Strict IANA Encoding Checking */ //@{ - /** + /** * This function enables/disables strict IANA encoding names checking. * * The strict checking is disabled by default. @@ -740,15 +729,15 @@ public : */ static bool isStrictIANAEncoding(); //@} - + /** * Aligns the specified pointer per platform block allocation - * requirements. - * - * The results of this function may be altered by defining - * XML_PLATFORM_NEW_BLOCK_ALIGNMENT. - */ - static inline size_t alignPointerForNewBlockAllocation(size_t ptrSize); + * requirements. + * + * The results of this function may be altered by defining + * XML_PLATFORM_NEW_BLOCK_ALIGNMENT. + */ + static inline size_t alignPointerForNewBlockAllocation(size_t ptrSize); private : // ----------------------------------------------------------------------- @@ -789,22 +778,6 @@ private : */ static XMLTransService* makeTransService(); - /** Does initialization for a particular platform - * - * Each per-platform driver must implement this to do any low level - * system initialization required. It <b>cannot</b> use any XML - * parser or utilities services! - */ - static void platformInit(); - - /** Does termination for a particular platform - * - * Each per-platform driver must implement this to do any low level - * system resource cleanup required. It <b>cannot</b> use any XML - * parser or utilities services! - */ - static void platformTerm(); - /** Search for sequence, slash dot dot slash * * @param srcPath the path to search @@ -838,8 +811,8 @@ MakeXMLException(XMLPlatformUtilsException, XMLUTIL_EXPORT) // XMLPlatformUtils: alignPointerForNewBlockAllocation // --------------------------------------------------------------------------- // Calculate alignment required by platform for a new -// block allocation. We use this in our custom allocators -// to ensure that returned blocks are properly aligned. +// block allocation. We use this in our custom allocators +// to ensure that returned blocks are properly aligned. // Note that, although this will take a pointer and return the position // at which it should be placed for correct alignment, in our code // we normally use size_t parameters to discover what the alignment @@ -859,23 +832,23 @@ MakeXMLException(XMLPlatformUtilsException, XMLUTIL_EXPORT) inline size_t XMLPlatformUtils::alignPointerForNewBlockAllocation(size_t ptrSize) { - // Macro XML_PLATFORM_NEW_BLOCK_ALIGNMENT may be defined - // as needed to dictate alignment requirements on a - // per-architecture basis. In the absense of that we - // take an educated guess. - #ifdef XML_PLATFORM_NEW_BLOCK_ALIGNMENT - size_t alignment = XML_PLATFORM_NEW_BLOCK_ALIGNMENT; - #else - size_t alignment = (sizeof(void*) >= sizeof(double)) ? sizeof(void*) : sizeof(double); - #endif - - // Calculate current alignment of pointer - size_t current = ptrSize % alignment; - - // Adjust pointer alignment as needed - return (current == 0) - ? ptrSize - : (ptrSize + alignment - current); + // Macro XML_PLATFORM_NEW_BLOCK_ALIGNMENT may be defined + // as needed to dictate alignment requirements on a + // per-architecture basis. In the absense of that we + // take an educated guess. +#ifdef XML_PLATFORM_NEW_BLOCK_ALIGNMENT + static const size_t alignment = XML_PLATFORM_NEW_BLOCK_ALIGNMENT; +#else + static const size_t alignment = (sizeof(void*) >= sizeof(double)) ? sizeof(void*) : sizeof(double); +#endif + + // Calculate current alignment of pointer + size_t current = ptrSize % alignment; + + // Adjust pointer alignment as needed + return (current == 0) + ? ptrSize + : (ptrSize + alignment - current); }