You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by lm...@apache.org on 2001/07/20 19:27:16 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/validators/common Grammar.java

lmartin     01/07/20 10:27:16

  Modified:    java/src/org/apache/xerces/validators/common Grammar.java
  Log:
  Performance patches related to array resizing - submitted by Henry Zongaro
  
  Revision  Changes    Path
  1.29      +13 -22    xml-xerces/java/src/org/apache/xerces/validators/common/Grammar.java
  
  Index: Grammar.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/common/Grammar.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- Grammar.java	2001/06/20 20:54:38	1.28
  +++ Grammar.java	2001/07/20 17:27:16	1.29
  @@ -72,7 +72,7 @@
   
   
   /**
  - * @version $Id: Grammar.java,v 1.28 2001/06/20 20:54:38 neilg Exp $
  + * @version $Id: Grammar.java,v 1.29 2001/07/20 17:27:16 lmartin Exp $
    */
   public class Grammar
   implements XMLContentSpec.Provider {
  @@ -997,10 +997,8 @@
   
       // ensure capacity
   
  -    private boolean ensureElementDeclCapacity(int chunk) {
  -        try {
  -            return fElementDeclName[chunk][0] == null;
  -        } catch (ArrayIndexOutOfBoundsException ex) {
  +    private void ensureElementDeclCapacity(int chunk) {
  +        if (chunk >= fElementDeclName.length) {
               fElementDeclName = resize(fElementDeclName, fElementDeclName.length * 2);
               fElementDeclType = resize(fElementDeclType, fElementDeclType.length * 2);
               fElementDeclDatatypeValidator = resize(fElementDeclDatatypeValidator, fElementDeclDatatypeValidator.length * 2);
  @@ -1010,8 +1008,8 @@
               fElementDeclUnique = resize(fElementDeclUnique, fElementDeclUnique.length * 2);
               fElementDeclKey = resize(fElementDeclKey, fElementDeclKey.length * 2);
               fElementDeclKeyRef = resize(fElementDeclKeyRef, fElementDeclKeyRef.length * 2);
  -        } catch (NullPointerException ex) {
  -            // ignore
  +        } else if (fElementDeclName[chunk] != null) {
  +            return;
           }
           fElementDeclName[chunk] = new QName[CHUNK_SIZE];
           fElementDeclType[chunk] = new int[CHUNK_SIZE];
  @@ -1022,31 +1020,25 @@
           fElementDeclUnique[chunk] = new Vector[CHUNK_SIZE];
           fElementDeclKey[chunk] = new Vector[CHUNK_SIZE];
           fElementDeclKeyRef[chunk] = new Vector[CHUNK_SIZE];
  -        return true;
       }
   
  -    private boolean ensureContentSpecCapacity(int chunk) {
  -        try {
  -            return fContentSpecType[chunk][0] == 0;
  -        } catch (ArrayIndexOutOfBoundsException ex) {
  +    private void ensureContentSpecCapacity(int chunk) {
  +        if (chunk >= fContentSpecType.length) {
               fContentSpecType = resize(fContentSpecType, fContentSpecType.length * 2);
               fContentSpecValue = resize(fContentSpecValue, fContentSpecValue.length * 2);
               fContentSpecOtherValue = resize(fContentSpecOtherValue, fContentSpecOtherValue.length * 2);
               fContentSpecValidator = resize(fContentSpecValidator, fContentSpecValidator.length * 2);
  -        } catch (NullPointerException ex) {
  -            // ignore
  +        } else if (fContentSpecType[chunk] != null) {
  +            return;
           }
           fContentSpecType[chunk] = new int[CHUNK_SIZE];
           fContentSpecValue[chunk] = new int[CHUNK_SIZE];
           fContentSpecOtherValue[chunk] = new int[CHUNK_SIZE];
           fContentSpecValidator[chunk] = new XMLContentModel[CHUNK_SIZE];
  -        return true;
       }
   
  -    private boolean ensureAttributeDeclCapacity(int chunk) {
  -        try {
  -            return fAttributeDeclName[chunk][0] == null;
  -        } catch (ArrayIndexOutOfBoundsException ex) {
  +    private void ensureAttributeDeclCapacity(int chunk) {
  +        if (chunk >= fAttributeDeclName.length) {
               fAttributeDeclName = resize(fAttributeDeclName, fAttributeDeclName.length * 2);
               fAttributeDeclType = resize(fAttributeDeclType, fAttributeDeclType.length * 2);
               fAttributeDeclEnumeration = resize(fAttributeDeclEnumeration, fAttributeDeclEnumeration.length * 2);
  @@ -1054,8 +1046,8 @@
               fAttributeDeclDatatypeValidator = resize(fAttributeDeclDatatypeValidator, fAttributeDeclDatatypeValidator.length * 2);
               fAttributeDeclDefaultValue = resize(fAttributeDeclDefaultValue, fAttributeDeclDefaultValue.length * 2);
               fAttributeDeclNextAttributeDeclIndex = resize(fAttributeDeclNextAttributeDeclIndex, fAttributeDeclNextAttributeDeclIndex.length * 2);
  -        } catch (NullPointerException ex) {
  -            // ignore
  +        } else if (fAttributeDeclName[chunk] != null) {
  +            return;
           }
           fAttributeDeclName[chunk] = new QName[CHUNK_SIZE];
           fAttributeDeclType[chunk] = new int[CHUNK_SIZE];
  @@ -1064,7 +1056,6 @@
           fAttributeDeclDatatypeValidator[chunk] = new DatatypeValidator[CHUNK_SIZE];
           fAttributeDeclDefaultValue[chunk] = new String[CHUNK_SIZE];
           fAttributeDeclNextAttributeDeclIndex[chunk] = new int[CHUNK_SIZE];
  -        return true;
       }
   
       // resize initial chunk
  
  
  

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