Author: amassari
Date: Tue Oct  1 18:23:57 2013
New Revision: 1528170

URL: http://svn.apache.org/r1528170
Log:
DOMDocument now stores the "big buffers" in a separate list, so that incomplete 
DOMText nodes can be released when parsing long strings (XERCESC-2019)

Modified:
    xerces/c/trunk/projects/Win32/VC9/xerces-all/xerces-all.sln
    xerces/c/trunk/src/xercesc/dom/impl/DOMCharacterDataImpl.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMCharacterDataImpl.hpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.hpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMStringPool.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMStringPool.hpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMTextImpl.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMTextImpl.hpp
    xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp

Modified: xerces/c/trunk/projects/Win32/VC9/xerces-all/xerces-all.sln
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/projects/Win32/VC9/xerces-all/xerces-all.sln?rev=1528170&r1=1528169&r2=1528170&view=diff
==============================================================================
--- xerces/c/trunk/projects/Win32/VC9/xerces-all/xerces-all.sln (original)
+++ xerces/c/trunk/projects/Win32/VC9/xerces-all/xerces-all.sln Tue Oct  1 
18:23:57 2013
@@ -2,35 +2,36 @@ Microsoft Visual Studio Solution File, F
 # Visual Studio 2008
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "all", "all\all.vcproj", 
"{E305E46C-9D74-4755-BF57-29DEAEF4DCDD}"
        ProjectSection(ProjectDependencies) = postProject
-               {895EDBF3-6A97-4641-8D96-7282005F8DD7} = 
{895EDBF3-6A97-4641-8D96-7282005F8DD7}
-               {15A10DF2-F551-4306-A4CC-690F58C58081} = 
{15A10DF2-F551-4306-A4CC-690F58C58081}
-               {B8B50FE7-B620-4D19-A147-B167D087DD53} = 
{B8B50FE7-B620-4D19-A147-B167D087DD53}
-               {FB7E86DB-9557-4044-8FF7-A9131BB021E6} = 
{FB7E86DB-9557-4044-8FF7-A9131BB021E6}
-               {7259B5D2-54FE-4142-9321-0572C615F0A2} = 
{7259B5D2-54FE-4142-9321-0572C615F0A2}
-               {0D9CB6CF-DB0B-495D-B674-8FC3DD3C12C2} = 
{0D9CB6CF-DB0B-495D-B674-8FC3DD3C12C2}
-               {65BE6CCA-6F7F-4DB9-A6FD-C220E9FE87AD} = 
{65BE6CCA-6F7F-4DB9-A6FD-C220E9FE87AD}
-               {D3552FBC-8618-43C5-86C0-237536D8E700} = 
{D3552FBC-8618-43C5-86C0-237536D8E700}
-               {DFC196B9-2146-4CDA-AC0A-632BD38FA41D} = 
{DFC196B9-2146-4CDA-AC0A-632BD38FA41D}
-               {3C777DB7-42D1-4AA6-A051-24213E411891} = 
{3C777DB7-42D1-4AA6-A051-24213E411891}
-               {959445AC-9081-4590-B457-C96164CF4BFA} = 
{959445AC-9081-4590-B457-C96164CF4BFA}
-               {2682B2AB-E341-4528-85AB-BE95DE77A9BC} = 
{2682B2AB-E341-4528-85AB-BE95DE77A9BC}
-               {2AB767A9-6A3B-4993-8FDB-3E6A30560739} = 
{2AB767A9-6A3B-4993-8FDB-3E6A30560739}
-               {056463A8-AEDD-4B92-BC24-C0C154C0379C} = 
{056463A8-AEDD-4B92-BC24-C0C154C0379C}
-               {FB794093-CA26-4DBF-A7DF-1A62B7C872D5} = 
{FB794093-CA26-4DBF-A7DF-1A62B7C872D5}
-               {60E3008A-0D78-4B25-A12E-9D7A3921F67C} = 
{60E3008A-0D78-4B25-A12E-9D7A3921F67C}
-               {6F412978-851F-494D-8C3D-DF97A515EDF5} = 
{6F412978-851F-494D-8C3D-DF97A515EDF5}
-               {D2D5D167-5DBC-4B68-9AF0-B7A9EBE86284} = 
{D2D5D167-5DBC-4B68-9AF0-B7A9EBE86284}
-               {4D8FEA60-A74F-4267-852F-C421AF12198D} = 
{4D8FEA60-A74F-4267-852F-C421AF12198D}
-               {152CE948-F659-4206-A50A-1D2B9658EF96} = 
{152CE948-F659-4206-A50A-1D2B9658EF96}
+               {26A4FA00-DB6E-43FA-83D4-0FC3A5472A27} = 
{26A4FA00-DB6E-43FA-83D4-0FC3A5472A27}
+               {569D5A1E-C582-40B7-8BFC-FC7B5D4DDA75} = 
{569D5A1E-C582-40B7-8BFC-FC7B5D4DDA75}
+               {117D4C21-4C54-478F-83AE-D6179A8D7EF1} = 
{117D4C21-4C54-478F-83AE-D6179A8D7EF1}
+               {792C0625-DE93-4756-AAFA-23CCED2157B0} = 
{792C0625-DE93-4756-AAFA-23CCED2157B0}
+               {8709DC2A-0EC9-4B67-9E98-95D5174B2C3F} = 
{8709DC2A-0EC9-4B67-9E98-95D5174B2C3F}
+               {BBD46C34-DEA0-42AB-96AB-E87C6371A6C2} = 
{BBD46C34-DEA0-42AB-96AB-E87C6371A6C2}
+               {2230D938-8908-4C12-9E96-9C6C4048A52D} = 
{2230D938-8908-4C12-9E96-9C6C4048A52D}
                {160AC448-AD35-4FA9-8C4D-FF46A0E5BE5D} = 
{160AC448-AD35-4FA9-8C4D-FF46A0E5BE5D}
+               {152CE948-F659-4206-A50A-1D2B9658EF96} = 
{152CE948-F659-4206-A50A-1D2B9658EF96}
+               {4D8FEA60-A74F-4267-852F-C421AF12198D} = 
{4D8FEA60-A74F-4267-852F-C421AF12198D}
+               {D2D5D167-5DBC-4B68-9AF0-B7A9EBE86284} = 
{D2D5D167-5DBC-4B68-9AF0-B7A9EBE86284}
+               {6F412978-851F-494D-8C3D-DF97A515EDF5} = 
{6F412978-851F-494D-8C3D-DF97A515EDF5}
+               {60E3008A-0D78-4B25-A12E-9D7A3921F67C} = 
{60E3008A-0D78-4B25-A12E-9D7A3921F67C}
+               {FB794093-CA26-4DBF-A7DF-1A62B7C872D5} = 
{FB794093-CA26-4DBF-A7DF-1A62B7C872D5}
+               {056463A8-AEDD-4B92-BC24-C0C154C0379C} = 
{056463A8-AEDD-4B92-BC24-C0C154C0379C}
+               {2AB767A9-6A3B-4993-8FDB-3E6A30560739} = 
{2AB767A9-6A3B-4993-8FDB-3E6A30560739}
+               {2682B2AB-E341-4528-85AB-BE95DE77A9BC} = 
{2682B2AB-E341-4528-85AB-BE95DE77A9BC}
+               {959445AC-9081-4590-B457-C96164CF4BFA} = 
{959445AC-9081-4590-B457-C96164CF4BFA}
                {BE9C14B1-2301-4C62-85E2-B583D22AE29C} = 
{BE9C14B1-2301-4C62-85E2-B583D22AE29C}
-               {2230D938-8908-4C12-9E96-9C6C4048A52D} = 
{2230D938-8908-4C12-9E96-9C6C4048A52D}
-               {BBD46C34-DEA0-42AB-96AB-E87C6371A6C2} = 
{BBD46C34-DEA0-42AB-96AB-E87C6371A6C2}
-               {8709DC2A-0EC9-4B67-9E98-95D5174B2C3F} = 
{8709DC2A-0EC9-4B67-9E98-95D5174B2C3F}
-               {792C0625-DE93-4756-AAFA-23CCED2157B0} = 
{792C0625-DE93-4756-AAFA-23CCED2157B0}
-               {117D4C21-4C54-478F-83AE-D6179A8D7EF1} = 
{117D4C21-4C54-478F-83AE-D6179A8D7EF1}
-               {569D5A1E-C582-40B7-8BFC-FC7B5D4DDA75} = 
{569D5A1E-C582-40B7-8BFC-FC7B5D4DDA75}
-               {26A4FA00-DB6E-43FA-83D4-0FC3A5472A27} = 
{26A4FA00-DB6E-43FA-83D4-0FC3A5472A27}
+               {3C777DB7-42D1-4AA6-A051-24213E411891} = 
{3C777DB7-42D1-4AA6-A051-24213E411891}
+               {DFC196B9-2146-4CDA-AC0A-632BD38FA41D} = 
{DFC196B9-2146-4CDA-AC0A-632BD38FA41D}
+               {D3552FBC-8618-43C5-86C0-237536D8E700} = 
{D3552FBC-8618-43C5-86C0-237536D8E700}
+               {65BE6CCA-6F7F-4DB9-A6FD-C220E9FE87AD} = 
{65BE6CCA-6F7F-4DB9-A6FD-C220E9FE87AD}
+               {0D9CB6CF-DB0B-495D-B674-8FC3DD3C12C2} = 
{0D9CB6CF-DB0B-495D-B674-8FC3DD3C12C2}
+               {7259B5D2-54FE-4142-9321-0572C615F0A2} = 
{7259B5D2-54FE-4142-9321-0572C615F0A2}
+               {FB7E86DB-9557-4044-8FF7-A9131BB021E6} = 
{FB7E86DB-9557-4044-8FF7-A9131BB021E6}
+               {D92806DD-C591-4782-BCF2-8A0D0338D67A} = 
{D92806DD-C591-4782-BCF2-8A0D0338D67A}
+               {B8B50FE7-B620-4D19-A147-B167D087DD53} = 
{B8B50FE7-B620-4D19-A147-B167D087DD53}
+               {15A10DF2-F551-4306-A4CC-690F58C58081} = 
{15A10DF2-F551-4306-A4CC-690F58C58081}
+               {895EDBF3-6A97-4641-8D96-7282005F8DD7} = 
{895EDBF3-6A97-4641-8D96-7282005F8DD7}
        EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateDOMDocument", 
"CreateDOMDocument\CreateDOMDocument.vcproj", 
"{8709DC2A-0EC9-4B67-9E98-95D5174B2C3F}"

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMCharacterDataImpl.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMCharacterDataImpl.cpp?rev=1528170&r1=1528169&r2=1528170&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMCharacterDataImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMCharacterDataImpl.cpp Tue Oct  1 
18:23:57 2013
@@ -108,11 +108,21 @@ void DOMCharacterDataImpl::appendData(co
 
 void DOMCharacterDataImpl::appendData(const DOMNode *node, const  XMLCh *dat, 
XMLSize_t n)
 {
-  if(castToNodeImpl(node)->isReadOnly())
+    if(castToNodeImpl(node)->isReadOnly())
         throw DOMException(
         DOMException::NO_MODIFICATION_ALLOWED_ERR, 0, 
GetDOMCharacterDataImplMemoryManager);
 
-  fDataBuf->append(dat, n);
+    fDataBuf->append(dat, n);
+}
+
+void DOMCharacterDataImpl::appendDataFast(const DOMNode *node, const  XMLCh 
*dat, XMLSize_t n)
+{
+    // This function makes the following assumptions:
+    //
+    // - this node is not read-only
+    // - nobody has ever received a pointer to the current content of fDataBuf,
+    //   so it can be safely released
+    fDataBuf->appendInPlace(dat, n);
 }
 
 void DOMCharacterDataImpl::deleteData(const DOMNode *node, XMLSize_t offset, 
XMLSize_t count)

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMCharacterDataImpl.hpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMCharacterDataImpl.hpp?rev=1528170&r1=1528169&r2=1528170&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMCharacterDataImpl.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMCharacterDataImpl.hpp Tue Oct  1 
18:23:57 2013
@@ -62,6 +62,7 @@ public:
     void           setNodeValue(const XMLCh * value);
     void           appendData(const DOMNode *node, const  XMLCh *data);
     void           appendData(const DOMNode *node, const  XMLCh *data, 
XMLSize_t n);
+    void           appendDataFast(const DOMNode *node, const  XMLCh *data, 
XMLSize_t n);
     void           deleteData(const DOMNode *node, XMLSize_t offset, XMLSize_t 
count);
     const XMLCh*   getData() const;
     XMLSize_t      getLength() const;

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.cpp?rev=1528170&r1=1528169&r2=1528170&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.cpp Tue Oct  1 18:23:57 
2013
@@ -91,6 +91,7 @@ DOMDocumentImpl::DOMDocumentImpl(DOMImpl
       fUserDataTableKeys(17, manager),
       fUserDataTable(0),
       fCurrentBlock(0),
+      fCurrentSingletonBlock(0),
       fFreePtr(0),
       fFreeBytesRemaining(0),
       fHeapAllocSize(kInitialHeapAllocSize),
@@ -133,6 +134,7 @@ DOMDocumentImpl::DOMDocumentImpl(const X
       fUserDataTableKeys(17, manager),
       fUserDataTable(0),
       fCurrentBlock(0),
+      fCurrentSingletonBlock(0),
       fFreePtr(0),
       fFreeBytesRemaining(0),
       fHeapAllocSize(kInitialHeapAllocSize),
@@ -829,6 +831,26 @@ void DOMDocumentImpl::setMemoryAllocatio
         fHeapAllocSize=size;
 }
 
+void DOMDocumentImpl::release(void* oldBuffer)
+{
+    // only release blocks that are stored in a block by itself
+    XMLSize_t sizeOfHeader = 
XMLPlatformUtils::alignPointerForNewBlockAllocation(sizeof(void *));
+    void** cursor = &fCurrentSingletonBlock;
+    while (*cursor != 0)
+    {
+        void **nextBlock = (void **)(*cursor);
+        if ((char*)(*cursor) + sizeOfHeader == oldBuffer)
+        {
+            // found: deallocate and replace the pointer value with the next 
block
+            void* current = *cursor;
+            *cursor = *nextBlock;
+            fMemoryManager->deallocate(current);
+            break;
+        }
+        cursor = nextBlock;
+    }
+}
+
 void* DOMDocumentImpl::allocate(XMLSize_t amount)
 {
   //   Align the request size so that suballocated blocks
@@ -836,31 +858,28 @@ void* DOMDocumentImpl::allocate(XMLSize_
   amount = XMLPlatformUtils::alignPointerForNewBlockAllocation(amount);
 
   // If the request is for a largish block, hand it off to the system
-  //   allocator.  The block still must be linked into the list of
-  //   allocated blocks so that it will be deleted when the time comes.
+  //   allocator.  The block still must be linked into a special list of
+  //   allocated big blocks so that it will be deleted when the time comes.
   if (amount > kMaxSubAllocationSize)
   {
     // The size of the header we add to our raw blocks
     XMLSize_t sizeOfHeader = 
XMLPlatformUtils::alignPointerForNewBlockAllocation(sizeof(void *));
 
     // Try to allocate the block
-    void* newBlock;
-    newBlock = fMemoryManager->allocate(sizeOfHeader + amount);
+    void* newBlock = fMemoryManager->allocate(sizeOfHeader + amount);
 
     // Link it into the list beyond current block, as current block
     // is still being subdivided. If there is no current block
     // then track that we have no bytes to further divide.
-    if (fCurrentBlock)
+    if (fCurrentSingletonBlock)
     {
-      *(void **)newBlock = *(void **)fCurrentBlock;
-      *(void **)fCurrentBlock = newBlock;
+      *(void **)newBlock = *(void **)fCurrentSingletonBlock;
+      *(void **)fCurrentSingletonBlock = newBlock;
     }
     else
     {
       *(void **)newBlock = 0;
-      fCurrentBlock = newBlock;
-      fFreePtr = 0;
-      fFreeBytesRemaining = 0;
+      fCurrentSingletonBlock = newBlock;
     }
 
     void *retPtr = (char*)newBlock + sizeOfHeader;
@@ -905,6 +924,12 @@ void DOMDocumentImpl::deleteHeap()
         fMemoryManager->deallocate(fCurrentBlock);
         fCurrentBlock = nextBlock;
     }
+    while (fCurrentSingletonBlock != 0)
+    {
+        void *nextBlock = *(void **)fCurrentSingletonBlock;
+        fMemoryManager->deallocate(fCurrentSingletonBlock);
+        fCurrentSingletonBlock = nextBlock;
+    }
 }
 
 

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.hpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.hpp?rev=1528170&r1=1528169&r2=1528170&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.hpp Tue Oct  1 18:23:57 
2013
@@ -159,6 +159,8 @@ public:
     virtual void setMemoryAllocationBlockSize(XMLSize_t size);
     virtual void* allocate(XMLSize_t amount);
     virtual void* allocate(XMLSize_t amount, DOMMemoryManager::NodeObjectType 
type);
+    // try to remove the block from the list of allocated memory
+    virtual void release(void* oldBuffer);
     virtual void release(DOMNode* object, DOMMemoryManager::NodeObjectType 
type);
     virtual XMLCh* cloneString(const XMLCh *src);
 
@@ -320,6 +322,7 @@ protected:
     //                  class, rather than hanging naked on Document.
     //
     void*                 fCurrentBlock;
+    void*                 fCurrentSingletonBlock;
     char*                 fFreePtr;
     XMLSize_t             fFreeBytesRemaining,
                           fHeapAllocSize;

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMStringPool.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMStringPool.cpp?rev=1528170&r1=1528169&r2=1528170&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMStringPool.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMStringPool.cpp Tue Oct  1 18:23:57 
2013
@@ -44,7 +44,7 @@ DOMBuffer(DOMDocumentImpl *doc, XMLSize_
 // ---------------------------------------------------------------------------
 //  DOMBuffer: Private helper methods
 // ---------------------------------------------------------------------------
-void DOMBuffer::expandCapacity(const XMLSize_t extraNeeded)
+void DOMBuffer::expandCapacity(const XMLSize_t extraNeeded, bool 
releasePrevious /*= false*/)
 {
     //not enough room. Calc new capacity and allocate new buffer
     const XMLSize_t newCap = (XMLSize_t)((fIndex + extraNeeded) * 1.25);
@@ -53,7 +53,12 @@ void DOMBuffer::expandCapacity(const XML
     // Copy over the old stuff
     memcpy(newBuf, fBuffer, fCapacity * sizeof(XMLCh));
 
-    // revisit: Leave the old buffer in document heap, yes, this is a leak, 
but live with it!
+    // If the caller told us to deallocate the old memory, do it;
+    // it may know that nobody could possibly get a pointer to the old memory 
buffer
+    // (e.g. if the DOM node is being created by the parser). Otherwise leave 
the old 
+    // buffer in document heap; yes, this is a leak, but live with it!
+    if (releasePrevious)
+        fDoc->release(fBuffer);
     // store new stuff
     fBuffer = newBuf;
     fCapacity = newCap;

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMStringPool.hpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMStringPool.hpp?rev=1528170&r1=1528169&r2=1528170&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMStringPool.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMStringPool.hpp Tue Oct  1 18:23:57 
2013
@@ -75,6 +75,7 @@ public :
     // -----------------------------------------------------------------------
     void append (const XMLCh* const chars);
     void append (const XMLCh* const chars, const XMLSize_t count);
+    void appendInPlace (const XMLCh* const chars, const XMLSize_t count);
 
     void set (const XMLCh* const chars);
     void set (const XMLCh* const chars, const XMLSize_t count);
@@ -117,7 +118,7 @@ public :
     // -----------------------------------------------------------------------
     //  Private helpers
     // -----------------------------------------------------------------------
-    void expandCapacity(const XMLSize_t extraNeeded);
+    void expandCapacity(const XMLSize_t extraNeeded, bool releasePrevious = 
false);
 
 
 private :
@@ -179,6 +180,19 @@ append (const XMLCh* const chars, const 
 }
 
 inline void DOMBuffer::
+appendInPlace (const XMLCh* const chars, const XMLSize_t count)
+{
+  if (fIndex + count >= fCapacity)
+    expandCapacity(count, true);
+
+  memcpy(&fBuffer[fIndex], chars, count * sizeof(XMLCh));
+  fIndex += count;
+
+  // Keep it null terminated
+  fBuffer[fIndex] = 0;
+}
+
+inline void DOMBuffer::
 set (const XMLCh* const chars)
 {
   XMLSize_t count = XMLString::stringLen(chars);

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMTextImpl.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMTextImpl.cpp?rev=1528170&r1=1528169&r2=1528170&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMTextImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMTextImpl.cpp Tue Oct  1 18:23:57 2013
@@ -154,26 +154,26 @@ const XMLCh* DOMTextImpl::getWholeText()
     pWalker->setCurrentNode((DOMNode*)this);
     // Logically-adjacent text nodes are Text or CDATASection nodes that can 
be visited sequentially in document order or in
     // reversed document order without entering, exiting, or passing over 
Element, Comment, or ProcessingInstruction nodes.
-       DOMNode* prevNode;
+    DOMNode* prevNode;
     while((prevNode=pWalker->previousNode())!=NULL)
     {
         if(prevNode->getNodeType()==ELEMENT_NODE || 
prevNode->getNodeType()==COMMENT_NODE || 
prevNode->getNodeType()==PROCESSING_INSTRUCTION_NODE)
             break;
     }
-       XMLBuffer buff(1023, GetDOMNodeMemoryManager);
-       DOMNode* nextNode;
+    XMLBuffer buff(1023, GetDOMNodeMemoryManager);
+    DOMNode* nextNode;
     while((nextNode=pWalker->nextNode())!=NULL)
     {
         if(nextNode->getNodeType()==ELEMENT_NODE || 
nextNode->getNodeType()==COMMENT_NODE || 
nextNode->getNodeType()==PROCESSING_INSTRUCTION_NODE)
             break;
         if(nextNode->getNodeType()==TEXT_NODE || 
nextNode->getNodeType()==CDATA_SECTION_NODE)
-               buff.append(nextNode->getNodeValue());
+            buff.append(nextNode->getNodeValue());
     }
     pWalker->release();
 
-       XMLCh* wholeString = 
(XMLCh*)((DOMDocumentImpl*)doc)->allocate((buff.getLen()+1) * sizeof(XMLCh));
-       XMLString::copyString(wholeString, buff.getRawBuffer());
-       return wholeString;
+    XMLCh* wholeString = 
(XMLCh*)((DOMDocumentImpl*)doc)->allocate((buff.getLen()+1) * sizeof(XMLCh));
+    XMLString::copyString(wholeString, buff.getRawBuffer());
+    return wholeString;
 }
 
 DOMText* DOMTextImpl::replaceWholeText(const XMLCh* newText)
@@ -184,7 +184,7 @@ DOMText* DOMTextImpl::replaceWholeText(c
     // Logically-adjacent text nodes are Text or CDATASection nodes that can 
be visited sequentially in document order or in
     // reversed document order without entering, exiting, or passing over 
Element, Comment, or ProcessingInstruction nodes.
     DOMNode* pFirstTextNode=this;
-       DOMNode* prevNode;
+    DOMNode* prevNode;
     while((prevNode=pWalker->previousNode())!=NULL)
     {
         if(prevNode->getNodeType()==ELEMENT_NODE || 
prevNode->getNodeType()==COMMENT_NODE || 
prevNode->getNodeType()==PROCESSING_INSTRUCTION_NODE)
@@ -193,7 +193,7 @@ DOMText* DOMTextImpl::replaceWholeText(c
     }
     // before doing any change we need to check if we are going to remove an 
entity reference that doesn't contain just text
     DOMNode* pCurrentNode=pWalker->getCurrentNode();
-       DOMNode* nextNode;
+    DOMNode* nextNode;
     while((nextNode=pWalker->nextNode())!=NULL)
     {
         if(nextNode->getNodeType()==ELEMENT_NODE || 
nextNode->getNodeType()==COMMENT_NODE || 
nextNode->getNodeType()==PROCESSING_INSTRUCTION_NODE)
@@ -327,5 +327,6 @@ void DOMTextImpl::release()
           void              DOMTextImpl::setNodeValue(const XMLCh  *nodeValue) 
  {fCharacterData.setNodeValue (this, nodeValue); }
 
           void              DOMTextImpl::appendData(const XMLCh *arg, 
XMLSize_t n) {fCharacterData.appendData(this, arg, n);}
+          void              DOMTextImpl::appendDataFast(const XMLCh *arg, 
XMLSize_t n) {fCharacterData.appendDataFast(this, arg, n);}
 
 XERCES_CPP_NAMESPACE_END

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMTextImpl.hpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMTextImpl.hpp?rev=1528170&r1=1528169&r2=1528170&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMTextImpl.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMTextImpl.hpp Tue Oct  1 18:23:57 2013
@@ -86,6 +86,7 @@ public:
     // Non-standard extension.
     //
     virtual void            appendData(const XMLCh *arg, XMLSize_t n);
+    void                    appendDataFast(const XMLCh *arg, XMLSize_t n);
 
 protected:
     virtual void            setIgnorableWhitespace(bool ignorable);

Modified: xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp?rev=1528170&r1=1528169&r2=1528170&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp (original)
+++ xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp Tue Oct  1 
18:23:57 2013
@@ -803,7 +803,7 @@ void AbstractDOMParser::docCharacters(  
         if (fCurrentNode->getNodeType() == DOMNode::TEXT_NODE)
         {
             DOMTextImpl *node = (DOMTextImpl*)fCurrentNode;
-            node->appendData(chars, length);
+            node->appendDataFast(chars, length);
         }
         else
         {
@@ -908,25 +908,18 @@ void AbstractDOMParser::ignorableWhitesp
     if (!fWithinElement || !fIncludeIgnorableWhitespace)
         return;
 
-    // revisit.  Not safe to slam in a null like this.
-    XMLCh savedChar = chars[length];
-    XMLCh *ncChars  = (XMLCh *)chars;   // cast off const
-    ncChars[length] = chNull;
-
     if (fCurrentNode->getNodeType() == DOMNode::TEXT_NODE)
     {
-        DOMText *node = (DOMText *)fCurrentNode;
-        node->appendData(chars);
+        DOMTextImpl *node = (DOMTextImpl *)fCurrentNode;
+        node->appendDataFast(chars, length);
     }
     else
     {
-        DOMTextImpl *node = (DOMTextImpl *)fDocument->createTextNode(chars);
+        DOMTextImpl *node = (DOMTextImpl*)createText (chars, length);
         node->setIgnorableWhitespace(true);
         castToParentImpl (fCurrentParent)->appendChildFast (node);
-
         fCurrentNode = node;
     }
-    ncChars[length] = savedChar;
 }
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to