You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by bo...@apache.org on 2008/03/03 17:31:47 UTC
svn commit: r633162 - in /xerces/c/trunk/src/xercesc:
dom/impl/DOMParentNode.cpp dom/impl/DOMParentNode.hpp
parsers/AbstractDOMParser.cpp util/regx/RegularExpression.hpp
Author: borisk
Date: Mon Mar 3 08:31:46 2008
New Revision: 633162
URL: http://svn.apache.org/viewvc?rev=633162&view=rev
Log:
Apply the fast DOM child append patch (XERCESC-1735). Squash a few warnings.
Modified:
xerces/c/trunk/src/xercesc/dom/impl/DOMParentNode.cpp
xerces/c/trunk/src/xercesc/dom/impl/DOMParentNode.hpp
xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp
xerces/c/trunk/src/xercesc/util/regx/RegularExpression.hpp
Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMParentNode.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMParentNode.cpp?rev=633162&r1=633161&r2=633162&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMParentNode.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMParentNode.cpp Mon Mar 3 08:31:46 2008
@@ -350,6 +350,49 @@
}
+DOMNode * DOMParentNode::appendChildFast(DOMNode *newChild)
+{
+ // This function makes the following assumptions:
+ //
+ // - newChild != 0
+ // - newChild is not read-only
+ // - newChild is not a document fragment
+ // - owner documents of this node and newChild are the same
+ // - appending newChild to this node cannot result in a cycle
+ // - DOMDocumentImpl::isKidOK (this, newChild) return true (that is,
+ // appending newChild to this node results in a valid structure)
+ // - newChild->getParentNode() is 0
+ // - there are no ranges set for this document
+ //
+
+ // Attach up
+ castToNodeImpl(newChild)->fOwnerNode = castToNode(this);
+ castToNodeImpl(newChild)->isOwned(true);
+
+ // Attach before and after
+ // Note: fFirstChild.previousSibling == lastChild!!
+ if (fFirstChild != 0)
+ {
+ DOMNode *lastChild = castToChildImpl(fFirstChild)->previousSibling;
+ castToChildImpl(lastChild)->nextSibling = newChild;
+ castToChildImpl(newChild)->previousSibling = lastChild;
+ castToChildImpl(fFirstChild)->previousSibling = newChild;
+ }
+ else
+ {
+ // this our first and only child
+ fFirstChild = newChild;
+ castToNodeImpl(newChild)->isFirstChild(true);
+ // castToChildImpl(newChild)->previousSibling = newChild;
+ DOMChildNode *newChild_ci = castToChildImpl(newChild);
+ newChild_ci->previousSibling = newChild;
+ }
+
+ changed();
+
+ return newChild;
+}
+
//Introduced in DOM Level 2
Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMParentNode.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMParentNode.hpp?rev=633162&r1=633161&r2=633162&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMParentNode.hpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMParentNode.hpp Mon Mar 3 08:31:46 2008
@@ -82,6 +82,10 @@
DOMNode* removeChild(DOMNode *oldChild);
DOMNode* replaceChild(DOMNode *newChild, DOMNode *oldChild);
+ // Append certain types of nodes fast. Used to speed up XML to DOM
+ // parsing. See the function implementation for detail.
+ DOMNode* appendChildFast(DOMNode *newChild);
+
//Introduced in DOM Level 2
void normalize();
Modified: xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp?rev=633162&r1=633161&r2=633162&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp (original)
+++ xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp Mon Mar 3 08:31:46 2008
@@ -59,6 +59,7 @@
#include <xercesc/dom/DOMProcessingInstruction.hpp>
#include <xercesc/dom/impl/DOMProcessingInstructionImpl.hpp>
#include <xercesc/dom/impl/DOMNodeIDMap.hpp>
+#include <xercesc/dom/impl/DOMCasts.hpp>
#include <xercesc/validators/common/ContentSpecNode.hpp>
#include <xercesc/validators/common/GrammarResolver.hpp>
#include <xercesc/validators/schema/SchemaSymbols.hpp>
@@ -785,7 +786,7 @@
if (cdataSection == true)
{
DOMCDATASection *node = fDocument->createCDATASection(chars);
- fCurrentParent->appendChild(node);
+ castToParentImpl (fCurrentParent)->appendChildFast (node);
fCurrentNode = node;
}
else
@@ -798,7 +799,7 @@
else
{
DOMText *node = fDocument->createTextNode(chars);
- fCurrentParent->appendChild(node);
+ castToParentImpl (fCurrentParent)->appendChildFast (node);
fCurrentNode = node;
}
}
@@ -811,7 +812,7 @@
{
if (fCreateCommentNodes) {
DOMComment *dcom = fDocument->createComment(comment);
- fCurrentParent->appendChild(dcom);
+ castToParentImpl (fCurrentParent)->appendChildFast (dcom);
fCurrentNode = dcom;
}
}
@@ -825,7 +826,7 @@
target
, data
);
- fCurrentParent->appendChild(pi);
+ castToParentImpl (fCurrentParent)->appendChildFast (pi);
fCurrentNode = pi;
}
@@ -893,7 +894,7 @@
{
DOMTextImpl *node = (DOMTextImpl *)fDocument->createTextNode(chars);
node->setIgnorableWhitespace(true);
- fCurrentParent->appendChild(node);
+ castToParentImpl (fCurrentParent)->appendChildFast (node);
fCurrentNode = node;
}
@@ -1130,8 +1131,10 @@
}
}
-
- fCurrentParent->appendChild(elem);
+ if (fCurrentParent != fDocument)
+ castToParentImpl (fCurrentParent)->appendChildFast (elem);
+ else
+ fCurrentParent->appendChild (elem);
fNodeStack->push(fCurrentParent);
fCurrentParent = elem;
@@ -1164,7 +1167,7 @@
DOMEntityReferenceImpl *erImpl = (DOMEntityReferenceImpl *) er;
erImpl->setReadOnly(false, true);
- fCurrentParent->appendChild(er);
+ castToParentImpl (fCurrentParent)->appendChildFast (er);
fNodeStack->push(fCurrentParent);
fCurrentParent = er;
Modified: xerces/c/trunk/src/xercesc/util/regx/RegularExpression.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/RegularExpression.hpp?rev=633162&r1=633161&r2=633162&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/RegularExpression.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/RegularExpression.hpp Mon Mar 3 08:31:46 2008
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -89,7 +89,7 @@
static const unsigned int PROHIBIT_FIXED_STRING_OPTIMIZATION;
static const unsigned int XMLSCHEMA_MODE;
static const unsigned int SPECIAL_COMMA;
- typedef enum
+ typedef enum
{
wordTypeIgnore = 0,
wordTypeLetter = 1,
@@ -184,7 +184,7 @@
void reset(const XMLCh* const string, const XMLSize_t stringLen,
const XMLSize_t start, const XMLSize_t limit, const int noClosures);
bool nextCh(XMLInt32& ch, XMLSize_t& offset, const short direction);
-
+
bool fAdoptMatch;
XMLSize_t fStart;
XMLSize_t fLimit;
@@ -330,7 +330,7 @@
inline void RegularExpression::cleanUp() {
fMemoryManager->deallocate(fPattern);//delete [] fPattern;
- fMemoryManager->deallocate(fFixedString);//delete [] fFixedString;
+ fMemoryManager->deallocate(fFixedString);//delete [] fFixedString;
delete fBMPattern;
delete fTokenFactory;
}
@@ -372,6 +372,8 @@
((const ModifierToken *) token)->getOptions(),
((const ModifierToken *) token)->getOptionsMask());
break;
+ default:
+ break;
}
@@ -406,6 +408,8 @@
break;
case Token::T_BACKREFERENCE:
ret = fOpFactory.createBackReferenceOp(token->getReferenceNo());
+ break;
+ default:
break;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org