Author: mrglavas
Date: Mon Dec 20 22:14:58 2010
New Revision: 1051303

URL: http://svn.apache.org/viewvc?rev=1051303&view=rev
Log:
Some minor improvements for performance and to also make it easier for 
applications which use object identity for comparing schema components... Only 
create the XSParticle and XSWildcard once for xs:anyType. Return the empty list 
singleton instead of creating a new one when there are no attribute uses.

Modified:
    xerces/java/trunk/src/org/apache/xerces/impl/xs/SchemaGrammar.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/SchemaGrammar.java
URL: 
http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/SchemaGrammar.java?rev=1051303&r1=1051302&r2=1051303&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/SchemaGrammar.java 
(original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/SchemaGrammar.java Mon Dec 
20 22:14:58 2010
@@ -1177,8 +1177,8 @@ public class SchemaGrammar implements XS
             fDerivedBy = XSConstants.DERIVATION_RESTRICTION;
             fContentType = XSComplexTypeDecl.CONTENTTYPE_MIXED;
 
-            fParticle = null;
-            fAttrGrp = null;
+            fParticle = createParticle();
+            fAttrGrp = createAttrGrp();
         }
 
         // overridden methods
@@ -1210,25 +1210,23 @@ public class SchemaGrammar implements XS
             // null implementation
         }
 
-        public XSObjectList getAttributeUses() {
+        public XSObjectList getAnnotations() {
             return XSObjectListImpl.EMPTY_LIST;
         }
-
-        public XSAttributeGroupDecl getAttrGrp() {
+        
+        public XSNamespaceItem getNamespaceItem() {
+            return SG_SchemaNS;
+        }
+        
+        private XSAttributeGroupDecl createAttrGrp() {
             XSWildcardDecl wildcard = new XSWildcardDecl();
             wildcard.fProcessContents = XSWildcardDecl.PC_LAX;
             XSAttributeGroupDecl attrGrp = new XSAttributeGroupDecl();
             attrGrp.fAttributeWC = wildcard;
             return attrGrp;
-        }
-
-        public XSWildcard getAttributeWildcard() {
-            XSWildcardDecl wildcard = new XSWildcardDecl();
-            wildcard.fProcessContents = XSWildcardDecl.PC_LAX;
-            return wildcard;
-        }
-
-        public XSParticle getParticle() {
+        }   
+        
+        private XSParticleDecl createParticle() {
             // the wildcard used in anyType (content and attribute)
             // the spec will change strict to skip for anyType
             XSWildcardDecl wildcard = new XSWildcardDecl();
@@ -1252,14 +1250,6 @@ public class SchemaGrammar implements XS
         
             return particleG;
         }
-
-        public XSObjectList getAnnotations() {
-            return XSObjectListImpl.EMPTY_LIST;
-        }
-        
-        public XSNamespaceItem getNamespaceItem() {
-            return SG_SchemaNS;
-        }
     }
     private static class BuiltinAttrDecl extends XSAttributeDecl {
         public BuiltinAttrDecl(String name, String tns, 

Modified: 
xerces/java/trunk/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java
URL: 
http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java?rev=1051303&r1=1051302&r2=1051303&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java 
(original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java 
Mon Dec 20 22:14:58 2010
@@ -358,8 +358,13 @@ public class XSAttributeGroupDecl implem
      * {attribute uses} A set of attribute uses.
      */
     public XSObjectList getAttributeUses() {
-        if (fAttrUses == null){
-            fAttrUses = new XSObjectListImpl(fAttributeUses, fAttrUseNum);
+        if (fAttrUses == null) {
+            if (fAttrUseNum > 0) {
+                fAttrUses = new XSObjectListImpl(fAttributeUses, fAttrUseNum);
+            }
+            else {
+                fAttrUses = XSObjectListImpl.EMPTY_LIST;
+            }
         }
         return fAttrUses;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to