From bdc8e29b491bc8448349e4584ec0a0079044f40c Mon Sep 17 00:00:00 2001 From: Tinny Ng <tng@apache.org> Date: Wed, 7 Nov 2001 21:12:15 +0000 Subject: [PATCH] Performance: Create QName in ContentSpecNode only if it is a leaf/Any*/PCDataNode. git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@173205 13f79535-47bb-0310-9956-ffa450edef68 --- src/validators/DTD/DTDElementDecl.cpp | 8 +++++--- src/validators/common/ContentSpecNode.cpp | 2 +- src/validators/common/ContentSpecNode.hpp | 17 +++++++++-------- src/validators/schema/ComplexTypeInfo.cpp | 17 ++++++++++++----- .../schema/SubstitutionGroupComparator.cpp | 9 +++++++++ 5 files changed, 36 insertions(+), 17 deletions(-) diff --git a/src/validators/DTD/DTDElementDecl.cpp b/src/validators/DTD/DTDElementDecl.cpp index 9e105799a..76aebd402 100644 --- a/src/validators/DTD/DTDElementDecl.cpp +++ b/src/validators/DTD/DTDElementDecl.cpp @@ -359,11 +359,13 @@ XMLContentModel* DTDElementDecl::createChildModel() ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); // - // Do a sanity check that the node is does not have a PCDATA id. Since, + // Do a sanity check that the node does not have a PCDATA id. Since, // if it was, it should have already gotten taken by the Mixed model. // - if (specNode->getElement()->getURI() == XMLElementDecl::fgPCDataElemId) - ThrowXML(RuntimeException, XMLExcepts::CM_NoPCDATAHere); + if (specNode->getElement()) { + if (specNode->getElement()->getURI() == XMLElementDecl::fgPCDataElemId) + ThrowXML(RuntimeException, XMLExcepts::CM_NoPCDATAHere); + } // // According to the type of node, we will create the correct type of diff --git a/src/validators/common/ContentSpecNode.cpp b/src/validators/common/ContentSpecNode.cpp index 8de61584e..7b58b45bb 100644 --- a/src/validators/common/ContentSpecNode.cpp +++ b/src/validators/common/ContentSpecNode.cpp @@ -84,7 +84,7 @@ ContentSpecNode::ContentSpecNode(const ContentSpecNode& toCopy) if (tempElement) fElement = new QName(tempElement); else - fElement = new QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, XMLElementDecl::fgInvalidElemId); + fElement = 0; const ContentSpecNode *tmp = toCopy.getFirst(); if (tmp) diff --git a/src/validators/common/ContentSpecNode.hpp b/src/validators/common/ContentSpecNode.hpp index 7979855dc..847cde5a3 100644 --- a/src/validators/common/ContentSpecNode.hpp +++ b/src/validators/common/ContentSpecNode.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.17 2001/11/07 21:12:15 tng + * Performance: Create QName in ContentSpecNode only if it is a leaf/Any*/PCDataNode. + * * Revision 1.16 2001/08/28 20:21:08 peiyongz * * AIX 4.2, xlC 3 rev.1 compilation error: get*() declared with external linkage * and called or defined before being declared as inline @@ -230,8 +233,8 @@ private : // Private Data Members // // fElement - // If the type is Leaf, then this is the qName of the element. If the URI - // is fgPCDataElemId, then its a PCData node. + // If the type is Leaf/Any*, then this is the qName of the element. If the URI + // is fgPCDataElemId, then its a PCData node. Else, it is zero. // // fFirst // fSecond @@ -286,7 +289,6 @@ inline ContentSpecNode::ContentSpecNode() : , fMinOccurs(1) , fMaxOccurs(1) { - fElement = new QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, XMLElementDecl::fgInvalidElemId); } inline @@ -301,9 +303,7 @@ ContentSpecNode::ContentSpecNode(QName* const element) : , fMinOccurs(1) , fMaxOccurs(1) { - if (!element) - fElement = new QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, XMLElementDecl::fgInvalidElemId); - else + if (element) fElement = new QName(element); } @@ -323,7 +323,6 @@ ContentSpecNode::ContentSpecNode(const NodeTypes type , fMinOccurs(1) , fMaxOccurs(1) { - fElement = new QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, XMLElementDecl::fgInvalidElemId); } @@ -420,7 +419,9 @@ inline bool ContentSpecNode::isSecondAdopted() const inline void ContentSpecNode::setElement(QName* const element) { delete fElement; - fElement = new QName(element); + fElement = 0; + if (element) + fElement = new QName(element); } inline void ContentSpecNode::setFirst(ContentSpecNode* const toAdopt) diff --git a/src/validators/schema/ComplexTypeInfo.cpp b/src/validators/schema/ComplexTypeInfo.cpp index c4978d9b7..b7c167277 100644 --- a/src/validators/schema/ComplexTypeInfo.cpp +++ b/src/validators/schema/ComplexTypeInfo.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.21 2001/11/07 21:12:15 tng + * Performance: Create QName in ContentSpecNode only if it is a leaf/Any*/PCDataNode. + * * Revision 1.20 2001/10/12 18:08:57 tng * make sure the second node exists before calling getType * @@ -434,8 +437,10 @@ XMLContentModel* ComplexTypeInfo::createChildModel(ContentSpecNode* specNode, co // Do a sanity check that the node is does not have a PCDATA id. Since, // if it was, it should have already gotten taken by the Mixed model. // - if (specNode->getElement()->getURI() == XMLElementDecl::fgPCDataElemId) - ThrowXML(RuntimeException, XMLExcepts::CM_NoPCDATAHere); + if (specNode->getElement()) { + if (specNode->getElement()->getURI() == XMLElementDecl::fgPCDataElemId) + ThrowXML(RuntimeException, XMLExcepts::CM_NoPCDATAHere); + } // // According to the type of node, we will create the correct type of @@ -540,9 +545,11 @@ ComplexTypeInfo::convertContentSpecTree(ContentSpecNode* const curNode, // When checking Unique Particle Attribution, rename leaf elements if (checkUPA) { - fContentSpecOrgURI[fUniqueURI] = curNode->getElement()->getURI(); - curNode->getElement()->setURI(fUniqueURI); - fUniqueURI++; + if (curNode->getElement()) { + fContentSpecOrgURI[fUniqueURI] = curNode->getElement()->getURI(); + curNode->getElement()->setURI(fUniqueURI); + fUniqueURI++; + } if (fUniqueURI == fContentSpecOrgURISize) resizeContentSpecOrgURI(); } diff --git a/src/validators/schema/SubstitutionGroupComparator.cpp b/src/validators/schema/SubstitutionGroupComparator.cpp index 61d4976f7..8d2f082b7 100644 --- a/src/validators/schema/SubstitutionGroupComparator.cpp +++ b/src/validators/schema/SubstitutionGroupComparator.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.8 2001/11/07 21:12:15 tng + * Performance: Create QName in ContentSpecNode only if it is a leaf/Any*/PCDataNode. + * * Revision 1.7 2001/10/04 15:08:56 knoaman * Add support for circular import. * @@ -90,6 +93,12 @@ bool SubstitutionGroupComparator::isEquivalentTo(QName* const anElement , QName* const exemplar) { + if (!anElement && !exemplar) + return true; + + if ((!anElement && exemplar) || (anElement && !exemplar)) + return false; + if ((XMLString::compareString(anElement->getLocalPart(), exemplar->getLocalPart()) == 0) && (anElement->getURI() == exemplar->getURI())) -- GitLab