santiagopg    2002/09/14 16:36:17

  Modified:    java/src/org/apache/xalan/xsltc/compiler Constants.java
                        SyntaxTreeNode.java
               java/src/org/apache/xalan/xsltc/compiler/util
                        ResultTreeType.java
               java/src/org/apache/xalan/xsltc/dom DOMImpl.java
  Log:
  Set different initial sizes for DOMImpl arrays. The new values result
  in better performance for the average case.
  
  Revision  Changes    Path
  1.26      +3 -1      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Constants.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- Constants.java    26 Aug 2002 16:03:00 -0000      1.25
  +++ Constants.java    14 Sep 2002 23:36:16 -0000      1.26
  @@ -478,4 +478,6 @@
        = "http://xml.apache.org/xalan/xsltc";;
       public static final String FALLBACK_CLASS
        = "org.apache.xalan.xsltc.compiler.Fallback";
  +
  +    public static final int RTF_INITIAL_SIZE = 64;
   }
  
  
  
  1.22      +3 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java
  
  Index: SyntaxTreeNode.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- SyntaxTreeNode.java       26 Aug 2002 16:03:00 -0000      1.21
  +++ SyntaxTreeNode.java       14 Sep 2002 23:36:16 -0000      1.22
  @@ -547,12 +547,12 @@
   
        final String DOM_CLASS = classGen.getDOMClass();
   
  -     // Create new instance of DOM class (with 64 nodes)
  +     // Create new instance of DOM class
        int index = cpg.addMethodref(DOM_IMPL, "<init>", "(I)V");
        il.append(new NEW(cpg.addClass(DOM_IMPL)));
        il.append(DUP);
        il.append(DUP);
  -     il.append(new PUSH(cpg, 64));
  +     il.append(new PUSH(cpg, RTF_INITIAL_SIZE));
        il.append(new INVOKESPECIAL(index));
   
        // Overwrite old handler with DOM handler
  
  
  
  1.13      +3 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ResultTreeType.java
  
  Index: ResultTreeType.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ResultTreeType.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ResultTreeType.java       26 Aug 2002 15:40:29 -0000      1.12
  +++ ResultTreeType.java       14 Sep 2002 23:36:17 -0000      1.13
  @@ -267,12 +267,12 @@
            }
            il.append(methodGen.loadDOM());
   
  -         // Create new instance of DOM class (with 64 nodes)
  +         // Create new instance of DOM class 
            int index = cpg.addMethodref(DOM_IMPL, "<init>", "(I)V");
            il.append(new NEW(cpg.addClass(DOM_IMPL)));
            il.append(DUP);
            il.append(DUP);
  -         il.append(new PUSH(cpg, 64));
  +         il.append(new PUSH(cpg, RTF_INITIAL_SIZE));
            il.append(new INVOKESPECIAL(index));
            
            // Store new DOM into a local variable
  
  
  
  1.82      +17 -11    
xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java
  
  Index: DOMImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java,v
  retrieving revision 1.81
  retrieving revision 1.82
  diff -u -r1.81 -r1.82
  --- DOMImpl.java      27 Aug 2002 16:55:26 -0000      1.81
  +++ DOMImpl.java      14 Sep 2002 23:36:17 -0000      1.82
  @@ -2225,24 +2225,30 @@
        _types         = setupMapping(_namesArray);
       }
   
  -    /**
  -     * Constructor - defaults to 32K nodes
  +    /*
  +     * These init sizes have been tuned for the average case. Do not
  +     * change these values unless you know exactly what you're doing.
        */
  +    static private final int SMALL_TEXT_SIZE   = 1024; 
  +    static private final int DEFAULT_INIT_SIZE = 1024;
  +    static private final int DEFAULT_TEXT_FACTOR = 10;
  +
       public DOMImpl() {
  -     //this(32*1024);
  -     this(8*1024);
  +     this(DEFAULT_INIT_SIZE);
       }
  -         
  -    /**
  -     * Constructor - defines initial size
  -     */
  +
       public DOMImpl(int size) {
  +     initialize(size, size < 128 ? SMALL_TEXT_SIZE : 
  +         size * DEFAULT_TEXT_FACTOR);
  +    }
  +         
  +    private void initialize(int size, int textsize) {
        _type          = new short[size];
        _parent        = new int[size];
        _nextSibling   = new int[size];
        _offsetOrChild = new int[size];
        _lengthOrAttr  = new int[size];
  -     _text          = new char[size * 10];
  +     _text          = new char[textsize];
        _whitespace    = new BitArray(size);
        _prefix        = new short[size];
        // _namesArray[] and _uriArray[] are allocated in endDocument
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to