You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2008/10/14 21:01:02 UTC

svn commit: r704620 - in /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs: XMLSchemaValidator.java traversers/XSAttributeChecker.java

Author: mrglavas
Date: Tue Oct 14 12:01:02 2008
New Revision: 704620

URL: http://svn.apache.org/viewvc?rev=704620&view=rev
Log:
Minor performance improvement. Iterate over the entries in the map instead 
of the keys. This avoids a redundant table lookup for each value.

Modified:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java?rev=704620&r1=704619&r2=704620&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java Tue Oct 14 12:01:02 2008
@@ -18,8 +18,9 @@
 package org.apache.xerces.impl.xs;
 
 import java.io.IOException;
-import java.util.Enumeration;
 import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
 import java.util.Stack;
 import java.util.Vector;
 
@@ -4110,21 +4111,25 @@
          * top of fGlobalMapStack into fGlobalIDConstraintMap.
          */
         public void endElement() {
-            if (fGlobalMapStack.isEmpty())
+            if (fGlobalMapStack.isEmpty()) {
                 return; // must be an invalid doc!
+            }
             Hashtable oldMap = (Hashtable) fGlobalMapStack.pop();
             // return if there is no element
-            if (oldMap == null)
+            if (oldMap == null) {
                 return;
+            }
 
-            Enumeration keys = oldMap.keys();
-            while (keys.hasMoreElements()) {
-                IdentityConstraint id = (IdentityConstraint) keys.nextElement();
-                ValueStoreBase oldVal = (ValueStoreBase) oldMap.get(id);
+            Iterator entries = oldMap.entrySet().iterator();
+            while (entries.hasNext()) {
+                Map.Entry entry = (Map.Entry) entries.next();
+                IdentityConstraint id = (IdentityConstraint) entry.getKey();
+                ValueStoreBase oldVal = (ValueStoreBase) entry.getValue();
                 if (oldVal != null) {
                     ValueStoreBase currVal = (ValueStoreBase) fGlobalIDConstraintMap.get(id);
-                    if (currVal == null)
+                    if (currVal == null) {
                         fGlobalIDConstraintMap.put(id, oldVal);
+                    }
                     else if (currVal != oldVal) {
                         currVal.append(oldVal);
                     }

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java?rev=704620&r1=704619&r2=704620&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java Tue Oct 14 12:01:02 2008
@@ -17,8 +17,9 @@
 
 package org.apache.xerces.impl.xs.traversers;
 
-import java.util.Enumeration;
 import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
 import java.util.StringTokenizer;
 import java.util.Vector;
 
@@ -1862,27 +1863,31 @@
     // REVISIT: pass the proper element node to reportSchemaError
     public void checkNonSchemaAttributes(XSGrammarBucket grammarBucket) {
         // for all attributes
-        Enumeration keys = fNonSchemaAttrs.keys();
+        Iterator entries = fNonSchemaAttrs.entrySet().iterator();
         XSAttributeDecl attrDecl;
-        while (keys.hasMoreElements()) {
+        while (entries.hasNext()) {
+            Map.Entry entry = (Map.Entry) entries.next();
             // get name, uri, localpart
-            String attrRName = (String)keys.nextElement();
+            String attrRName = (String) entry.getKey();
             String attrURI = attrRName.substring(0,attrRName.indexOf(','));
             String attrLocal = attrRName.substring(attrRName.indexOf(',')+1);
             // find associated grammar
             SchemaGrammar sGrammar = grammarBucket.getGrammar(attrURI);
-            if (sGrammar == null)
+            if (sGrammar == null) {
                 continue;
+            }
             // and get the datatype validator, if there is one
             attrDecl = sGrammar.getGlobalAttributeDecl(attrLocal);
-            if (attrDecl == null)
+            if (attrDecl == null) {
                 continue;
+            }
             XSSimpleType dv = (XSSimpleType)attrDecl.getTypeDefinition();
-            if (dv == null)
+            if (dv == null) {
                 continue;
+            }
 
             // get all values appeared with this attribute name
-            Vector values = (Vector)fNonSchemaAttrs.get(attrRName);
+            Vector values = (Vector) entry.getValue();
             String elName;
             String attrName = (String)values.elementAt(0);
             // for each of the values



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org