tng 2003/01/03 08:38:22
Modified: c/src/xercesc/validators/schema TraverseSchema.cpp
TraverseSchema.hpp
Log:
Performance: define fGlobalDeclarations as an array of ValueVectorOf to avoid string
comparison.
Revision Changes Path
1.48 +37 -17 xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.cpp
Index: TraverseSchema.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- TraverseSchema.cpp 3 Jan 2003 16:34:25 -0000 1.47
+++ TraverseSchema.cpp 3 Jan 2003 16:38:21 -0000 1.48
@@ -174,6 +174,17 @@
SchemaSymbols::fgELT_KEYREF
};
+// Flags for global declaration
+enum {
+ ENUM_ELT_SIMPLETYPE,
+ ENUM_ELT_COMPLEXTYPE,
+ ENUM_ELT_ELEMENT,
+ ENUM_ELT_ATTRIBUTE,
+ ENUM_ELT_ATTRIBUTEGROUP,
+ ENUM_ELT_GROUP,
+ ENUM_ELT_SIZE
+};
+
// ---------------------------------------------------------------------------
// TraverseSchema: Constructors and Destructor
// ---------------------------------------------------------------------------
@@ -4147,15 +4158,15 @@
else if (XMLString::equals(name, SchemaSymbols::fgELT_SIMPLETYPE)) {
if (typeName && *typeName) {
- if
(fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_SIMPLETYPE, fullNameId)
- ||
fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_COMPLEXTYPE, fullNameId)) {
+ if
(fGlobalDeclarations[ENUM_ELT_SIMPLETYPE]->containsElement(fullNameId)
+ ||
fGlobalDeclarations[ENUM_ELT_COMPLEXTYPE]->containsElement(fullNameId)) {
reportSchemaError(child, XMLUni::fgXMLErrDomain,
XMLErrs::DuplicateGlobalType,
SchemaSymbols::fgELT_SIMPLETYPE, typeName,
SchemaSymbols::fgELT_COMPLEXTYPE);
continue;
}
else {
- fGlobalDeclarations->put((void*)
SchemaSymbols::fgELT_SIMPLETYPE, fullNameId, 0);
+
fGlobalDeclarations[ENUM_ELT_SIMPLETYPE]->addElement(fullNameId);
}
}
@@ -4164,15 +4175,15 @@
else if (XMLString::equals(name, SchemaSymbols::fgELT_COMPLEXTYPE)) {
if (typeName && *typeName) {
- if
(fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_SIMPLETYPE, fullNameId)
- ||
fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_COMPLEXTYPE, fullNameId)) {
+ if
(fGlobalDeclarations[ENUM_ELT_SIMPLETYPE]->containsElement(fullNameId)
+ ||
fGlobalDeclarations[ENUM_ELT_COMPLEXTYPE]->containsElement(fullNameId)) {
reportSchemaError(child, XMLUni::fgXMLErrDomain,
XMLErrs::DuplicateGlobalType,
SchemaSymbols::fgELT_COMPLEXTYPE, typeName,
SchemaSymbols::fgELT_SIMPLETYPE);
continue;
}
else {
- fGlobalDeclarations->put((void*)
SchemaSymbols::fgELT_COMPLEXTYPE, fullNameId, 0);
+
fGlobalDeclarations[ENUM_ELT_COMPLEXTYPE]->addElement(fullNameId);
}
}
@@ -4181,14 +4192,14 @@
else if (XMLString::equals(name, SchemaSymbols::fgELT_ELEMENT)) {
if (typeName && *typeName) {
- if (fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_ELEMENT,
fullNameId)) {
+ if
(fGlobalDeclarations[ENUM_ELT_ELEMENT]->containsElement(fullNameId)) {
reportSchemaError(child, XMLUni::fgXMLErrDomain,
XMLErrs::DuplicateGlobalDeclaration,
SchemaSymbols::fgELT_ELEMENT, typeName);
continue;
}
else {
- fGlobalDeclarations->put((void*) SchemaSymbols::fgELT_ELEMENT,
fullNameId, 0);
+ fGlobalDeclarations[ENUM_ELT_ELEMENT]->addElement(fullNameId);
}
}
@@ -4198,14 +4209,14 @@
else if (XMLString::equals(name, SchemaSymbols::fgELT_ATTRIBUTEGROUP)) {
if (typeName && *typeName) {
- if
(fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_ATTRIBUTEGROUP, fullNameId)) {
+ if
(fGlobalDeclarations[ENUM_ELT_ATTRIBUTEGROUP]->containsElement(fullNameId)) {
reportSchemaError(child, XMLUni::fgXMLErrDomain,
XMLErrs::DuplicateGlobalDeclaration,
SchemaSymbols::fgELT_ATTRIBUTEGROUP,
typeName);
continue;
}
else {
- fGlobalDeclarations->put((void*)
SchemaSymbols::fgELT_ATTRIBUTEGROUP, fullNameId, 0);
+
fGlobalDeclarations[ENUM_ELT_ATTRIBUTEGROUP]->addElement(fullNameId);
}
}
@@ -4216,13 +4227,13 @@
else if (XMLString::equals(name, SchemaSymbols::fgELT_ATTRIBUTE)) {
if (typeName && *typeName) {
- if
(fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_ATTRIBUTE, fullNameId)) {
+ if
(fGlobalDeclarations[ENUM_ELT_ATTRIBUTE]->containsElement(fullNameId)) {
reportSchemaError(child, XMLUni::fgXMLErrDomain,
XMLErrs::DuplicateAttribute, typeName);
continue;
}
else {
- fGlobalDeclarations->put((void*)
SchemaSymbols::fgELT_ATTRIBUTE, fullNameId, 0);
+ fGlobalDeclarations[ENUM_ELT_ATTRIBUTE]->addElement(fullNameId);
}
}
@@ -4233,14 +4244,14 @@
else if (XMLString::equals(name, SchemaSymbols::fgELT_GROUP)) {
if (typeName && *typeName) {
- if (fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_GROUP,
fullNameId)) {
+ if
(fGlobalDeclarations[ENUM_ELT_GROUP]->containsElement(fullNameId)) {
reportSchemaError(child, XMLUni::fgXMLErrDomain,
XMLErrs::DuplicateGlobalDeclaration,
SchemaSymbols::fgELT_GROUP, typeName);
continue;
}
else {
- fGlobalDeclarations->put((void*) SchemaSymbols::fgELT_GROUP,
fullNameId, 0);
+ fGlobalDeclarations[ENUM_ELT_GROUP]->addElement(fullNameId);
}
}
@@ -7819,7 +7830,11 @@
fEmptyNamespaceURI = fScanner->getEmptyNamespaceId();
fCurrentTypeNameStack = new ValueVectorOf<unsigned int>(8);
fCurrentGroupStack = new ValueVectorOf<unsigned int>(8);
- fGlobalDeclarations = new RefHash2KeysTableOf<XMLCh>(29, false);
+
+ fGlobalDeclarations = new ValueVectorOf<unsigned int>*[ENUM_ELT_SIZE];
+ for(unsigned int i=0; i < ENUM_ELT_SIZE; i++)
+ fGlobalDeclarations[i] = new ValueVectorOf<unsigned int>(8);
+
fNotationRegistry = new RefHash2KeysTableOf<XMLCh>(13, false);
fSchemaInfoList = new RefHash2KeysTableOf<SchemaInfo>(29);
fPreprocessedNodes = new RefHashTableOf<SchemaInfo>(29, false, new HashPtr());
@@ -7832,7 +7847,12 @@
delete fSchemaInfoList;
delete fCurrentTypeNameStack;
delete fCurrentGroupStack;
- delete fGlobalDeclarations;
+
+ for(unsigned int i=0; i < ENUM_ELT_SIZE; i++)
+ delete fGlobalDeclarations[i];
+
+ delete [] fGlobalDeclarations;
+
delete fNotationRegistry;
delete fRedefineComponents;
delete fIdentityConstraintNames;
1.19 +13 -13 xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.hpp
Index: TraverseSchema.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.hpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- TraverseSchema.hpp 13 Dec 2002 21:16:11 -0000 1.18
+++ TraverseSchema.hpp 3 Jan 2003 16:38:21 -0000 1.19
@@ -128,11 +128,11 @@
~TraverseSchema();
private:
- // This enumeration is defined here for compatibility with the CodeWarrior
- // compiler, which apparently doesn't like to accept default parameter
- // arguments that it hasn't yet seen. The Not_All_Context argument is
- // used in the declaration of checkMinMax, below.
- //
+ // This enumeration is defined here for compatibility with the CodeWarrior
+ // compiler, which apparently doesn't like to accept default parameter
+ // arguments that it hasn't yet seen. The Not_All_Context argument is
+ // used in the declaration of checkMinMax, below.
+ //
// Flags indicate any special restrictions on minOccurs and maxOccurs
// relating to "all".
// Not_All_Context - not processing an <all>
@@ -749,7 +749,8 @@
RefHashTableOf<ComplexTypeInfo>* fComplexTypeRegistry;
RefHashTableOf<XercesGroupInfo>* fGroupRegistry;
RefHashTableOf<XercesAttGroupInfo>* fAttGroupRegistry;
- RefHash2KeysTableOf<SchemaInfo>* fSchemaInfoList;
+ RefHashTableOf<ElemVector>* fIC_ElementsNS;
+ RefHashTableOf<SchemaInfo>* fPreprocessedNodes;
SchemaInfo* fSchemaInfo;
XercesGroupInfo* fCurrentGroupInfo;
XercesAttGroupInfo* fCurrentAttGroupInfo;
@@ -759,17 +760,16 @@
ValueVectorOf<unsigned int>* fIC_NamespaceDepth;
ValueVectorOf<SchemaElementDecl*>* fIC_Elements;
ValueVectorOf<const DOMElement*>* fDeclStack;
- GeneralAttributeCheck fAttributeCheck;
- RefHash2KeysTableOf<XMLCh>* fGlobalDeclarations;
+ ValueVectorOf<unsigned int>** fGlobalDeclarations;
+ RefHashTableOf<ValueVectorOf<DOMElement*> >* fIC_NodeListNS;
+ RefHashTableOf<ValueVectorOf<unsigned int> >* fIC_NamespaceDepthNS;
RefHash2KeysTableOf<XMLCh>* fNotationRegistry;
RefHash2KeysTableOf<XMLCh>* fRedefineComponents;
RefHash2KeysTableOf<IdentityConstraint>* fIdentityConstraintNames;
RefHash2KeysTableOf<ElemVector>* fValidSubstitutionGroups;
- RefHashTableOf<ValueVectorOf<DOMElement*> >* fIC_NodeListNS;
- RefHashTableOf<ElemVector>* fIC_ElementsNS;
- RefHashTableOf<ValueVectorOf<unsigned int> >* fIC_NamespaceDepthNS;
+ RefHash2KeysTableOf<SchemaInfo>* fSchemaInfoList;
+ GeneralAttributeCheck fAttributeCheck;
XSDDOMParser* fParser;
- RefHashTableOf<SchemaInfo>* fPreprocessedNodes;
XSDErrorReporter fXSDErrorReporter;
XSDLocator* fLocator;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]