You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by tn...@apache.org on 2002/09/24 22:19:14 UTC
cvs commit: xml-xerces/c/src/xercesc/dom/impl DOMAttrNSImpl.cpp DOMDocumentImpl.cpp DOMElementNSImpl.cpp DOMNodeImpl.cpp DOMWriterImpl.cpp
tng 2002/09/24 13:19:14
Modified: c/src/xercesc/dom/impl DOMAttrNSImpl.cpp DOMDocumentImpl.cpp
DOMElementNSImpl.cpp DOMNodeImpl.cpp
DOMWriterImpl.cpp
Log:
Performance: use XMLString::equals instead of XMLString::compareString
and check for null string directly isntead of calling XMLString::stringLen
Revision Changes Path
1.8 +9 -9 xml-xerces/c/src/xercesc/dom/impl/DOMAttrNSImpl.cpp
Index: DOMAttrNSImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMAttrNSImpl.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DOMAttrNSImpl.cpp 16 Sep 2002 20:45:08 -0000 1.7
+++ DOMAttrNSImpl.cpp 24 Sep 2002 20:19:13 -0000 1.8
@@ -124,7 +124,7 @@
if (fNode.isReadOnly())
throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR,
0);
- if (fNamespaceURI == 0 || fNamespaceURI[0] == chNull || XMLString::compareString(fLocalName, xmlns) == 0)
+ if (fNamespaceURI == 0 || fNamespaceURI[0] == chNull || XMLString::equals(fLocalName, xmlns))
throw DOMException(DOMException::NAMESPACE_ERR, 0);
if (prefix != 0 && !DOMDocumentImpl::isXMLName(prefix))
@@ -136,10 +136,10 @@
return;
}
- if (XMLString::compareString(prefix, xml) == 0 &&
- XMLString::compareString(fNamespaceURI, xmlURI) != 0 ||
- XMLString::compareString(prefix, xmlns) == 0 &&
- XMLString::compareString(fNamespaceURI, xmlnsURI) != 0)
+ if (XMLString::equals(prefix, xml)&&
+ !XMLString::equals(fNamespaceURI, xmlURI)||
+ XMLString::equals(prefix, xmlns)&&
+ !XMLString::equals(fNamespaceURI, xmlnsURI))
throw DOMException(DOMException::NAMESPACE_ERR, 0);
if (XMLString::indexOf(prefix, chColon) != -1) {
@@ -215,8 +215,8 @@
bool xmlnsAlone = false; //true if attribute name is "xmlns"
if (index == 0) { //qualifiedName contains no ':'
- if (XMLString::compareString(this->fName, xmlns) == 0) {
- if (XMLString::compareString(namespaceURI, xmlnsURI) != 0)
+ if (XMLString::equals(this->fName, xmlns)) {
+ if (!XMLString::equals(namespaceURI, xmlnsURI))
throw DOMException(DOMException::NAMESPACE_ERR, 0);
xmlnsAlone = true;
}
@@ -248,7 +248,7 @@
: DOMNodeImpl::mapPrefix
(
fPrefix,
- (XMLString::stringLen(namespaceURI) == 0) ? 0 : namespaceURI,
+ (!namespaceURI || !*namespaceURI) ? 0 : namespaceURI,
DOMNode::ATTRIBUTE_NODE
);
this -> fNamespaceURI = (URI == 0) ? 0 : ownerDoc->getPooledString(URI);
1.24 +6 -4 xml-xerces/c/src/xercesc/dom/impl/DOMDocumentImpl.cpp
Index: DOMDocumentImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMDocumentImpl.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- DOMDocumentImpl.cpp 23 Sep 2002 19:41:07 -0000 1.23
+++ DOMDocumentImpl.cpp 24 Sep 2002 20:19:13 -0000 1.24
@@ -890,8 +890,8 @@
}
void DOMDocumentImpl::setVersion(const XMLCh* version){
- if (XMLString::stringLen(version) &&
- XMLString::compareString(version, XMLUni::fgSupportedVersion))
+ if ((version && *version) &&
+ !XMLString::equals(version, XMLUni::fgSupportedVersion))
throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0);
fVersion = cloneString(version);
@@ -903,7 +903,9 @@
}
void DOMDocumentImpl::setDocumentURI(const XMLCh* documentURI){
- fDocumentURI = cloneString(documentURI);
+ XMLCh* temp = (XMLCh*) this->allocate((XMLString::stringLen(documentURI) + 9)*sizeof(XMLCh));
+ XMLString::fixURI(documentURI, temp);
+ fDocumentURI = temp;
}
bool DOMDocumentImpl::getStrictErrorChecking() const {
1.9 +5 -5 xml-xerces/c/src/xercesc/dom/impl/DOMElementNSImpl.cpp
Index: DOMElementNSImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMElementNSImpl.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DOMElementNSImpl.cpp 23 Sep 2002 19:41:07 -0000 1.8
+++ DOMElementNSImpl.cpp 24 Sep 2002 20:19:14 -0000 1.9
@@ -122,7 +122,7 @@
DOMNode* attrNode = fAttributes->getNamedItemNS(DOMNodeImpl::getXmlURIString(), baseString);
if (attrNode) {
const XMLCh* uri = attrNode->getNodeValue();
- if (XMLString::stringLen(uri) != 0 ) {// attribute value is always empty string
+ if (uri && *uri) {// attribute value is always empty string
try {
XMLUri temp(baseURI);
XMLUri temp2(&temp, uri);
@@ -159,8 +159,8 @@
return;
}
- if (XMLString::compareString(prefix, xml) == 0 &&
- XMLString::compareString(fNamespaceURI, xmlURI) != 0)
+ if (XMLString::equals(prefix, xml) &&
+ !XMLString::equals(fNamespaceURI, xmlURI))
throw DOMException(DOMException::NAMESPACE_ERR, 0);
@@ -255,7 +255,7 @@
const XMLCh * URI = DOMNodeImpl::mapPrefix
(
fPrefix,
- (XMLString::stringLen(namespaceURI) == 0) ? 0 : namespaceURI,
+ (!namespaceURI || !*namespaceURI) ? 0 : namespaceURI,
DOMNode::ELEMENT_NODE
);
this -> fNamespaceURI = (URI == 0) ? 0 : ownerDoc->getPooledString(URI);
1.17 +26 -26 xml-xerces/c/src/xercesc/dom/impl/DOMNodeImpl.cpp
Index: DOMNodeImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMNodeImpl.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- DOMNodeImpl.cpp 23 Sep 2002 21:00:30 -0000 1.16
+++ DOMNodeImpl.cpp 24 Sep 2002 20:19:14 -0000 1.17
@@ -401,12 +401,12 @@
if (prefix == 0)
return namespaceURI;
- if (XMLString::compareString(prefix, s_xml) == 0) {
- if (XMLString::compareString(namespaceURI, s_xmlURI) == 0)
+ if (XMLString::equals(prefix, s_xml)) {
+ if (XMLString::equals(namespaceURI, s_xmlURI))
return s_xmlURI;
throw DOMException(DOMException::NAMESPACE_ERR, 0);
- } else if (nType == DOMNode::ATTRIBUTE_NODE && XMLString::compareString(prefix, s_xmlns) == 0) {
- if (XMLString::compareString(namespaceURI, s_xmlnsURI) == 0)
+ } else if (nType == DOMNode::ATTRIBUTE_NODE && XMLString::equals(prefix, s_xmlns)) {
+ if (XMLString::equals(namespaceURI, s_xmlnsURI))
return s_xmlnsURI;
throw DOMException(DOMException::NAMESPACE_ERR, 0);
} else if (namespaceURI == 0 || *namespaceURI == 0) {
@@ -462,27 +462,27 @@
}
// the compareString will check null string as well
- if (XMLString::compareString(thisNode->getNodeName(), arg->getNodeName())) {
+ if (!XMLString::equals(thisNode->getNodeName(), arg->getNodeName())) {
return false;
}
- if (XMLString::compareString(thisNode->getLocalName(),arg->getLocalName())) {
+ if (!XMLString::equals(thisNode->getLocalName(),arg->getLocalName())) {
return false;
}
- if (XMLString::compareString(thisNode->getNamespaceURI(), arg->getNamespaceURI())) {
+ if (!XMLString::equals(thisNode->getNamespaceURI(), arg->getNamespaceURI())) {
return false;
}
- if (XMLString::compareString(thisNode->getPrefix(), arg->getPrefix())) {
+ if (!XMLString::equals(thisNode->getPrefix(), arg->getPrefix())) {
return false;
}
- if (XMLString::compareString(thisNode->getNodeValue(), arg->getNodeValue())) {
+ if (!XMLString::equals(thisNode->getNodeValue(), arg->getNodeValue())) {
return false;
}
- if (XMLString::compareString(thisNode->getBaseURI(), arg->getBaseURI())) {
+ if (!XMLString::equals(thisNode->getBaseURI(), arg->getBaseURI())) {
return false;
}
@@ -553,10 +553,10 @@
// could be both?
const XMLCh* prefix = getPrefix();
- if (ns != 0 && (XMLString::compareString(ns,namespaceURI) == 0)) {
+ if (ns != 0 && XMLString::equals(ns,namespaceURI)) {
if (useDefault || prefix != 0) {
const XMLCh* foundNamespace = el->lookupNamespaceURI(prefix);
- if (foundNamespace != 0 && (XMLString::compareString(foundNamespace, namespaceURI) == 0)) {
+ if (foundNamespace != 0 && XMLString::equals(foundNamespace, namespaceURI)) {
return prefix;
}
}
@@ -574,14 +574,14 @@
ns = attr->getNamespaceURI();
- if (ns != 0 && (XMLString::compareString(ns, s_xmlnsURI) == 0)) {
+ if (ns != 0 && XMLString::equals(ns, s_xmlnsURI)) {
// DOM Level 2 nodes
- if ((useDefault && (XMLString::compareString(attr->getNodeName(), s_xmlns) == 0)) ||
- (attrPrefix != 0 && (XMLString::compareString(attrPrefix, s_xmlns) == 0)) &&
- (XMLString::compareString(value, namespaceURI) == 0)) {
+ if ((useDefault && XMLString::equals(attr->getNodeName(), s_xmlns)) ||
+ (attrPrefix != 0 && XMLString::equals(attrPrefix, s_xmlns)) &&
+ XMLString::equals(value, namespaceURI)) {
const XMLCh* localname= attr->getLocalName();
const XMLCh* foundNamespace = el->lookupNamespaceURI(localname);
- if (foundNamespace != 0 && (XMLString::compareString(foundNamespace, namespaceURI) == 0)) {
+ if (foundNamespace != 0 && XMLString::equals(foundNamespace, namespaceURI)) {
return localname;
}
}
@@ -609,7 +609,7 @@
if (specifiedPrefix == 0 && prefix == specifiedPrefix) {
// looking for default namespace
return ns;
- } else if (prefix != 0 && (XMLString::compareString(prefix, specifiedPrefix) == 0)) {
+ } else if (prefix != 0 && XMLString::equals(prefix, specifiedPrefix)) {
// non default namespace
return ns;
}
@@ -624,15 +624,15 @@
const XMLCh *value = attr->getNodeValue();
ns = attr->getNamespaceURI();
- if (ns != 0 && (XMLString::compareString(ns, s_xmlnsURI) == 0)) {
+ if (ns != 0 && XMLString::equals(ns, s_xmlnsURI)) {
// at this point we are dealing with DOM Level 2 nodes only
if (specifiedPrefix == 0 &&
- (XMLString::compareString(attr->getNodeName(), s_xmlns) == 0)) {
+ XMLString::equals(attr->getNodeName(), s_xmlns)) {
// default namespace
return value;
} else if (attrPrefix != 0 &&
- (XMLString::compareString(attrPrefix, s_xmlns) == 0) &&
- (XMLString::compareString(attr->getLocalName(), specifiedPrefix) == 0)) {
+ XMLString::equals(attrPrefix, s_xmlns) &&
+ XMLString::equals(attr->getLocalName(), specifiedPrefix)) {
// non default namespace
return value;
}
@@ -923,12 +923,12 @@
const XMLCh *prefix = thisNode->getPrefix();
// REVISIT: is it possible that prefix is empty string?
- if (prefix == 0 || XMLString::stringLen(prefix) == 0) {
+ if (prefix == 0 || !*prefix) {
const XMLCh* ns = thisNode->getNamespaceURI();
if (namespaceURI == 0) {
return (ns == namespaceURI);
}
- return (XMLString::compareString(namespaceURI, ns) == 0);
+ return XMLString::equals(namespaceURI, ns);
}
if (thisNode->hasAttributes()) {
@@ -936,7 +936,7 @@
DOMNode *attr = elem->getAttributeNodeNS(s_xmlnsURI, s_xmlns);
if (attr != 0) {
const XMLCh *value = attr->getNodeValue();
- return (XMLString::compareString(namespaceURI, value) == 0);
+ return XMLString::equals(namespaceURI, value);
}
}
DOMNode *ancestor = getElementAncestor(thisNode);
1.17 +17 -14 xml-xerces/c/src/xercesc/dom/impl/DOMWriterImpl.cpp
Index: DOMWriterImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMWriterImpl.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- DOMWriterImpl.cpp 9 Sep 2002 15:42:14 -0000 1.16
+++ DOMWriterImpl.cpp 24 Sep 2002 20:19:14 -0000 1.17
@@ -57,6 +57,10 @@
/*
* $Id$
* $Log$
+ * Revision 1.17 2002/09/24 20:19:14 tng
+ * Performance: use XMLString::equals instead of XMLString::compareString
+ * and check for null string directly isntead of calling XMLString::stringLen
+ *
* Revision 1.16 2002/09/09 15:42:14 peiyongz
* Patch to Bug#12369: invalid output from DOMWriter using MemBufFormatTarget
*
@@ -610,7 +614,7 @@
*/
fEncodingUsed = gUTF8;
- if (fEncoding && XMLString::stringLen(fEncoding))
+ if (fEncoding && *fEncoding)
{
fEncodingUsed = fEncoding;
}
@@ -622,7 +626,7 @@
{
const XMLCh* tmpEncoding = docu->getEncoding();
- if ( tmpEncoding && XMLString::stringLen(tmpEncoding))
+ if ( tmpEncoding && *tmpEncoding)
{
fEncodingUsed = tmpEncoding;
}
@@ -630,7 +634,7 @@
{
tmpEncoding = docu->getActualEncoding();
- if ( tmpEncoding && XMLString::stringLen(tmpEncoding))
+ if ( tmpEncoding && *tmpEncoding)
{
fEncodingUsed = tmpEncoding;
}
@@ -655,7 +659,7 @@
*
* The default value for this attribute is null
*/
- fNewLineUsed = (fNewLine && XMLString::stringLen(fNewLine))? fNewLine : gEOLSeq;
+ fNewLineUsed = (fNewLine && *fNewLine)? fNewLine : gEOLSeq;
fErrorCount = 0;
}
@@ -1119,7 +1123,7 @@
, int& featureId) const
{
// check for null and/or empty feature name
- if ((!featName) || (XMLString::stringLen(featName)==0))
+ if (!featName || !*featName)
{
if (toThrow)
throw DOMException(DOMException::NOT_FOUND_ERR, 0);
@@ -1129,21 +1133,21 @@
featureId = INVALID_FEATURE_ID;
- if (XMLString::compareString(featName, XMLUni::fgDOMWRTCanonicalForm)==0)
+ if (XMLString::equals(featName, XMLUni::fgDOMWRTCanonicalForm))
featureId = CANONICAL_FORM_ID;
- else if (XMLString::compareString(featName, XMLUni::fgDOMWRTDiscardDefaultContent)==0)
+ else if (XMLString::equals(featName, XMLUni::fgDOMWRTDiscardDefaultContent))
featureId = DISCARD_DEFAULT_CONTENT_ID;
- else if (XMLString::compareString(featName, XMLUni::fgDOMWRTEntities)==0)
+ else if (XMLString::equals(featName, XMLUni::fgDOMWRTEntities))
featureId = ENTITIES_ID;
- else if (XMLString::compareString(featName, XMLUni::fgDOMWRTFormatPrettyPrint)==0)
+ else if (XMLString::equals(featName, XMLUni::fgDOMWRTFormatPrettyPrint))
featureId = FORMAT_PRETTY_PRINT_ID;
- else if (XMLString::compareString(featName, XMLUni::fgDOMWRTNormalizeCharacters)==0)
+ else if (XMLString::equals(featName, XMLUni::fgDOMWRTNormalizeCharacters))
featureId = NORMALIZE_CHARACTERS_ID;
- else if (XMLString::compareString(featName, XMLUni::fgDOMWRTSplitCdataSections)==0)
+ else if (XMLString::equals(featName, XMLUni::fgDOMWRTSplitCdataSections))
featureId = SPLIT_CDATA_SECTIONS_ID;
- else if (XMLString::compareString(featName, XMLUni::fgDOMWRTValidation)==0)
+ else if (XMLString::equals(featName, XMLUni::fgDOMWRTValidation))
featureId = VALIDATION_ID;
- else if (XMLString::compareString(featName, XMLUni::fgDOMWRTWhitespaceInElementContent)==0)
+ else if (XMLString::equals(featName, XMLUni::fgDOMWRTWhitespaceInElementContent))
featureId = WHITESPACE_IN_ELEMENT_CONTENT_ID;
//feature name not resolvable
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org