Author: borisk
Date: Tue Jul 22 07:00:16 2008
New Revision: 678766

URL: http://svn.apache.org/viewvc?rev=678766&view=rev
Log:
XML to DOM parsing optimizations.

Modified:
    xerces/c/trunk/src/xercesc/dom/impl/DOMCharacterDataImpl.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMElementImpl.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMStringPool.cpp
    xerces/c/trunk/src/xercesc/dom/impl/DOMStringPool.hpp
    xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp
    xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.hpp
    xerces/c/trunk/src/xercesc/util/RefHashTableOf.hpp
    xerces/c/trunk/src/xercesc/validators/schema/XSDDOMParser.cpp

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=678766&r1=678765&r2=678766&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMCharacterDataImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMCharacterDataImpl.cpp Tue Jul 22 
07:00:16 2008
@@ -47,8 +47,10 @@
     fDoc = (DOMDocumentImpl*)doc;
 
     fDataBuf = fDoc->popBuffer(len+1);
+
     if (!fDataBuf)
         fDataBuf = new (fDoc) DOMBuffer(fDoc, len+15);
+
     fDataBuf->set(dat, len);
 }
 

Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMElementImpl.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMElementImpl.cpp?rev=678766&r1=678765&r2=678766&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMElementImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMElementImpl.cpp Tue Jul 22 07:00:16 
2008
@@ -53,7 +53,7 @@
         fAttributes = new (docImpl) DOMAttrMapImpl(this);
     }
     else {
-        fAttributes = new (docImpl) DOMAttrMapImpl(this, fDefaultAttributes);
+      fAttributes = new (docImpl) DOMAttrMapImpl(this, fDefaultAttributes);
     }
 }
 

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=678766&r1=678765&r2=678766&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMStringPool.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMStringPool.cpp Tue Jul 22 07:00:16 
2008
@@ -27,10 +27,8 @@
 
 XERCES_CPP_NAMESPACE_BEGIN
 
-// -----------------------------------------------------------------------
-//  DOMBuffer: Constructors
-// -----------------------------------------------------------------------
-DOMBuffer::DOMBuffer(DOMDocumentImpl *doc, XMLSize_t capacity) :
+DOMBuffer::
+DOMBuffer(DOMDocumentImpl *doc, XMLSize_t capacity) :
     fBuffer(0)
     , fIndex(0)
     , fCapacity(capacity)
@@ -44,39 +42,6 @@
 }
 
 // ---------------------------------------------------------------------------
-//  DOMBuffer: Buffer management
-// ---------------------------------------------------------------------------
-void DOMBuffer::append(const XMLCh* const chars, const XMLSize_t count)
-{
-    XMLSize_t actualCount = count;
-    if (!count)
-        actualCount = XMLString::stringLen(chars);
-    if (fIndex + actualCount >= fCapacity)
-        expandCapacity(actualCount);
-    memcpy(&fBuffer[fIndex], chars, actualCount * sizeof(XMLCh));
-    fIndex += actualCount;
-
-    // Keep it null terminated
-    fBuffer[fIndex] = 0;
-}
-
-void DOMBuffer::set(const XMLCh* const chars, const XMLSize_t count)
-{
-    XMLSize_t actualCount = count;
-    if (!count)
-        actualCount = XMLString::stringLen(chars);
-    fIndex = 0;
-    if (fIndex + actualCount >= fCapacity)
-        expandCapacity(actualCount);
-    memcpy(fBuffer, chars, actualCount * sizeof(XMLCh));
-    fIndex = actualCount;
-
-    // Keep it null terminated
-    fBuffer[fIndex] = 0;
-}
-
-
-// ---------------------------------------------------------------------------
 //  DOMBuffer: Private helper methods
 // ---------------------------------------------------------------------------
 void DOMBuffer::expandCapacity(const XMLSize_t extraNeeded)

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=678766&r1=678765&r2=678766&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMStringPool.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMStringPool.hpp Tue Jul 22 07:00:16 
2008
@@ -72,11 +72,11 @@
     // -----------------------------------------------------------------------
     //  Buffer Management
     // -----------------------------------------------------------------------
-    void append
-    (
-        const   XMLCh* const    chars
-        , const XMLSize_t       count = 0
-    );
+    void append (const XMLCh* const chars);
+    void append (const XMLCh* const chars, const XMLSize_t count);
+
+    void set (const XMLCh* const chars);
+    void set (const XMLCh* const chars, const XMLSize_t count);
 
     const XMLCh* getRawBuffer() const
     {
@@ -90,12 +90,6 @@
         fBuffer[0] = 0;
     }
 
-    void set
-    (
-        const   XMLCh* const    chars
-        , const XMLSize_t       count = 0
-    );
-
     void chop
     (
         const XMLSize_t    count
@@ -156,6 +150,62 @@
     DOMBuffer & operator = (const DOMBuffer &);
 };
 
+inline void DOMBuffer::
+append (const XMLCh* const chars)
+{
+  XMLSize_t count = XMLString::stringLen(chars);
+  if (fIndex + count >= fCapacity)
+    expandCapacity(count);
+
+  memcpy(&fBuffer[fIndex], chars, count * sizeof(XMLCh));
+  fIndex += count;
+
+  // Keep it null terminated
+  fBuffer[fIndex] = 0;
+}
+
+inline void DOMBuffer::
+append (const XMLCh* const chars, const XMLSize_t count)
+{
+  if (fIndex + count >= fCapacity)
+    expandCapacity(count);
+
+  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);
+  fIndex = 0;
+  if (count >= fCapacity)
+    expandCapacity(count);
+
+  memcpy(fBuffer, chars, count * sizeof(XMLCh));
+  fIndex = count;
+
+  // Keep it null terminated
+  fBuffer[fIndex] = 0;
+}
+
+inline void DOMBuffer::
+set (const XMLCh* const chars, const XMLSize_t count)
+{
+  fIndex = 0;
+  if (count >= fCapacity)
+    expandCapacity(count);
+
+  memcpy(fBuffer, chars, count * sizeof(XMLCh));
+  fIndex = count;
+
+  // Keep it null terminated
+  fBuffer[fIndex] = 0;
+}
+
 XERCES_CPP_NAMESPACE_END
 
 #endif

Modified: xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp?rev=678766&r1=678765&r2=678766&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp (original)
+++ xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp Tue Jul 22 
07:00:16 2008
@@ -97,7 +97,6 @@
 , fCurrentNode(0)
 , fCurrentEntity(0)
 , fDocument(0)
-, fNodeStack(0)
 , fDocumentType(0)
 , fDocumentVector(0)
 , fGrammarResolver(0)
@@ -149,7 +148,6 @@
     fScanner->setDocTypeHandler(this);
     fScanner->setURIStringPool(fURIStringPool);
 
-    fNodeStack = new (fMemoryManager) ValueStackOf<DOMNode*>(64, 
fMemoryManager);
     this->reset();
 }
 
@@ -161,7 +159,6 @@
     if (!fDocumentAdoptedByUser && fDocument)
         fDocument->release();
 
-    delete fNodeStack;
     delete fScanner;
     delete fGrammarResolver;
     // grammar pool *always* owns this
@@ -193,7 +190,6 @@
     fCurrentEntity   = 0;
     fWithinElement   = false;
     fDocumentAdoptedByUser = false;
-    fNodeStack->removeAllElements();
     fInternalSubset.reset();
 }
 
@@ -834,16 +830,16 @@
 
 void AbstractDOMParser::endEntityReference(const XMLEntityDecl&)
 {
-    if (!fCreateEntityReferenceNodes) return;
+    if (!fCreateEntityReferenceNodes)
+      return;
 
     DOMEntityReferenceImpl *erImpl = 0;
 
     if (fCurrentParent->getNodeType() == DOMNode::ENTITY_REFERENCE_NODE)
         erImpl = (DOMEntityReferenceImpl *) fCurrentParent;
 
-    fCurrentParent = fNodeStack->pop();
-
     fCurrentNode   = fCurrentParent;
+    fCurrentParent = fCurrentNode->getParentNode ();
 
     if (erImpl)
         erImpl->setReadOnly(true, true);
@@ -856,17 +852,18 @@
                            , const XMLCh* const)
 {
     fCurrentNode   = fCurrentParent;
-    fCurrentParent = fNodeStack->pop();
+    fCurrentParent = fCurrentNode->getParentNode ();
 
-    // If we've hit the end of content, clear the flag
-    if (fNodeStack->empty())
+    // If we've hit the end of content, clear the flag.
+    //
+    if (fCurrentParent == fDocument)
         fWithinElement = false;
 
     if(fDoXInclude && XIncludeUtils::isXIIncludeDOMNode(fCurrentNode)
         || (XIncludeUtils::isXIFallbackDOMNode(fCurrentNode) && 
!XMLString::equals(fCurrentParent->getNamespaceURI(), 
XIncludeUtils::fgXIIIncludeNamespaceURI)))
     {
        XIncludeUtils xiu((XMLErrorReporter *) this);
-           /* process the XInclude node, then update the fCurrentNode with the 
new content*/
+           // process the XInclude node, then update the fCurrentNode with the 
new content
            if(xiu.parseDOMNodeDoingXInclude(fCurrentNode, fDocument, 
getScanner()->getEntityHandler()))
             fCurrentNode = fCurrentParent->getLastChild();
     }
@@ -1164,7 +1161,6 @@
     else
       fCurrentParent->appendChild (elem);
 
-    fNodeStack->push(fCurrentParent);
     fCurrentParent = elem;
     fCurrentNode = elem;
     fWithinElement = true;
@@ -1197,7 +1193,6 @@
 
         castToParentImpl (fCurrentParent)->appendChildFast (er);
 
-        fNodeStack->push(fCurrentParent);
         fCurrentParent = er;
         fCurrentNode = er;
 

Modified: xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.hpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.hpp?rev=678766&r1=678765&r2=678766&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.hpp (original)
+++ xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.hpp Tue Jul 22 
07:00:16 2008
@@ -1690,9 +1690,6 @@
     //      for use in creating the DOMDocument used during parse. If this is
     //      null then the default DOMImplementation is used
     //
-    //  fNodeStack
-    //      Used to track previous parent nodes during nested element events.
-    //
     //  fParseInProgress
     //      Used to prevent multiple entrance to the parser while its doing
     //      a parse.
@@ -1747,7 +1744,6 @@
     DOMNode*                      fCurrentNode;
     DOMEntityImpl*                fCurrentEntity;
     DOMDocumentImpl*              fDocument;
-    ValueStackOf<DOMNode*>*       fNodeStack;
     DOMDocumentTypeImpl*          fDocumentType;
     RefVectorOf<DOMDocumentImpl>* fDocumentVector;
     GrammarResolver*              fGrammarResolver;

Modified: xerces/c/trunk/src/xercesc/util/RefHashTableOf.hpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/RefHashTableOf.hpp?rev=678766&r1=678765&r2=678766&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/RefHashTableOf.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/RefHashTableOf.hpp Tue Jul 22 07:00:16 2008
@@ -22,8 +22,6 @@
 #if !defined(XERCESC_INCLUDE_GUARD_REFHASHTABLEOF_HPP)
 #define XERCESC_INCLUDE_GUARD_REFHASHTABLEOF_HPP
 
-
-#include <xercesc/util/HashBase.hpp>
 #include <xercesc/util/IllegalArgumentException.hpp>
 #include <xercesc/util/NoSuchElementException.hpp>
 #include <xercesc/util/RuntimeException.hpp>

Modified: xerces/c/trunk/src/xercesc/validators/schema/XSDDOMParser.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/XSDDOMParser.cpp?rev=678766&r1=678765&r2=678766&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/XSDDOMParser.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/XSDDOMParser.cpp Tue Jul 22 
07:00:16 2008
@@ -365,7 +365,6 @@
     }
 
     fCurrentParent->appendChild(elem);
-    fNodeStack->push(fCurrentParent);
     fCurrentParent = elem;
     fCurrentNode = elem;
     fWithinElement = true;
@@ -402,12 +401,13 @@
         }
     }
 
-       fDepth--;
+    fDepth--;
     fCurrentNode   = fCurrentParent;
-    fCurrentParent = fNodeStack->pop();
+    fCurrentParent = fCurrentNode->getParentNode ();
 
-    // If we've hit the end of content, clear the flag
-    if (fNodeStack->empty())
+    // If we've hit the end of content, clear the flag.
+    //
+    if (fCurrentParent == fDocument)
         fWithinElement = false;
 }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to