morten      01/08/08 03:57:05

  Modified:    java/src/org/apache/xalan/xsltc/compiler Attribute.java
                        AttributeSet.java Copy.java UseAttributeSets.java
                        XslAttribute.java
               java/src/org/apache/xalan/xsltc/dom DOMImpl.java
  Log:
  Fix and performance improvement for attribute sets.
  PR:           bugzilla 2536
  Obtained from:        n/a
  Submitted by: [EMAIL PROTECTED]
  Reviewed by:  [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.4       +2 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Attribute.java
  
  Index: Attribute.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Attribute.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Attribute.java    2001/06/06 10:44:37     1.3
  +++ Attribute.java    2001/08/08 10:57:05     1.4
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Attribute.java,v 1.3 2001/06/06 10:44:37 morten Exp $
  + * @(#)$Id: Attribute.java,v 1.4 2001/08/08 10:57:05 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -73,7 +73,7 @@
        Util.println("Attribute " + _name);
        displayContents(indent + IndentIncrement);
       }
  -             
  +
       public void parseContents(Parser parser) {
        _name = parser.getQName(getAttribute("name"));
        parseChildren(parser);
  
  
  
  1.7       +13 -1     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AttributeSet.java
  
  Index: AttributeSet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AttributeSet.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AttributeSet.java 2001/07/10 17:45:04     1.6
  +++ AttributeSet.java 2001/08/08 10:57:05     1.7
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: AttributeSet.java,v 1.6 2001/07/10 17:45:04 morten Exp $
  + * @(#)$Id: AttributeSet.java,v 1.7 2001/08/08 10:57:05 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -225,5 +225,17 @@
        methodGen.setMaxStack();
        methodGen.removeNOPs();
        classGen.addMethod(methodGen.getMethod());
  +    }
  +
  +    public String toString() {
  +     StringBuffer buf = new StringBuffer("attribute-set: ");
  +     // Translate all local attributes
  +     final Enumeration attributes = elements();
  +     while (attributes.hasMoreElements()) {
  +         final XslAttribute attribute =
  +             (XslAttribute)attributes.nextElement();
  +         buf.append(attribute);
  +     }
  +     return(buf.toString());
       }
   }
  
  
  
  1.4       +3 -2      xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Copy.java
  
  Index: Copy.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Copy.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Copy.java 2001/06/06 10:44:48     1.3
  +++ Copy.java 2001/08/08 10:57:05     1.4
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Copy.java,v 1.3 2001/06/06 10:44:48 morten Exp $
  + * @(#)$Id: Copy.java,v 1.4 2001/08/08 10:57:05 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -105,6 +105,7 @@
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
        final String DOM_CLASS = classGen.getDOMClass();
  +
        final LocalVariableGen name =
            methodGen.addLocalVariable2("name",
                                        Util.getJCRefType(STRING_SIG),
  @@ -113,7 +114,7 @@
            methodGen.addLocalVariable2("length",
                                        Util.getJCRefType("I"),
                                        il.getEnd());
  -     
  +
        il.append(methodGen.loadDOM());
        il.append(methodGen.loadCurrentNode());
        il.append(methodGen.loadHandler());
  
  
  
  1.5       +5 -7      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/UseAttributeSets.java
  
  Index: UseAttributeSets.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/UseAttributeSets.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- UseAttributeSets.java     2001/06/11 12:52:58     1.4
  +++ UseAttributeSets.java     2001/08/08 10:57:05     1.5
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: UseAttributeSets.java,v 1.4 2001/06/11 12:52:58 morten Exp $
  + * @(#)$Id: UseAttributeSets.java,v 1.5 2001/08/08 10:57:05 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -64,7 +64,7 @@
   
   package org.apache.xalan.xsltc.compiler;
   
  -import java.util.HashSet;
  +import java.util.Vector;
   import java.util.Iterator;
   import java.util.Enumeration;
   import java.util.StringTokenizer;
  @@ -80,7 +80,7 @@
        "Attempting to use non-existing attribute set: ";
   
       // Contains the names of all references attribute sets
  -    private final HashSet _sets = new HashSet(3);
  +    private final Vector _sets = new Vector(2);
   
       /**
        * Constructur - define initial attribute sets to use
  @@ -121,12 +121,10 @@
        final InstructionList il = methodGen.getInstructionList();
        final SymbolTable symbolTable = getParser().getSymbolTable();
   
  -     // Get the QNames of the attribut sets we want to use
  -     final Iterator sets = _sets.iterator();
        // Go through each attribute set and generate a method call
  -     while (sets.hasNext()) {
  +     for (int i=0; i<_sets.size(); i++) {
            // Get the attribute set name
  -         final QName name = (QName)sets.next();
  +         final QName name = (QName)_sets.elementAt(i);
            // Get the AttributeSet reference from the symbol table
            final AttributeSet attrs = symbolTable.lookupAttributeSet(name);
            // Compile the call to the set's method if the set exists
  
  
  
  1.9       +21 -16    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XslAttribute.java
  
  Index: XslAttribute.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XslAttribute.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XslAttribute.java 2001/07/10 17:45:35     1.8
  +++ XslAttribute.java 2001/08/08 10:57:05     1.9
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: XslAttribute.java,v 1.8 2001/07/10 17:45:35 morten Exp $
  + * @(#)$Id: XslAttribute.java,v 1.9 2001/08/08 10:57:05 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -230,23 +230,28 @@
        il.append(methodGen.loadHandler());
        il.append(DUP);         // first arg to "attributes" call
        
  -     // push attribute name
  +     // Push attribute name
        _name.translate(classGen, methodGen);// 2nd arg
   
  -     il.append(classGen.loadTranslet());
  -     il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS,
  -                                            "stringValueHandler",
  -                                            STRING_VALUE_HANDLER_SIG)));
  -     il.append(DUP);
  -     il.append(methodGen.storeHandler());
  -
  -     // translate contents with substituted handler
  -     translateContents(classGen, methodGen);
  -
  -     // get String out of the handler
  -     il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_VALUE_HANDLER,
  -                                                  "getValue",
  -                                                  "()" + STRING_SIG)));
  +     // Push attribute value - shortcut for literal strings
  +     if ((elementCount() == 1) && (elementAt(0) instanceof Text)) {
  +         il.append(new PUSH(cpg, ((Text)elementAt(0)).getText()));
  +     }
  +     else {
  +         il.append(classGen.loadTranslet());
  +         il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS,
  +                                                "stringValueHandler",
  +                                                STRING_VALUE_HANDLER_SIG)));
  +         il.append(DUP);
  +         il.append(methodGen.storeHandler());
  +         // translate contents with substituted handler
  +         translateContents(classGen, methodGen);
  +         // get String out of the handler
  +         il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_VALUE_HANDLER,
  +                                                      "getValue",
  +                                                      "()" + STRING_SIG)));
  +     }
  +
        // call "attribute"
        il.append(methodGen.attribute());
        // Restore old handler base from stack
  
  
  
  1.18      +2 -2      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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- DOMImpl.java      2001/08/03 15:23:21     1.17
  +++ DOMImpl.java      2001/08/08 10:57:05     1.18
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: DOMImpl.java,v 1.17 2001/08/03 15:23:21 morten Exp $
  + * @(#)$Id: DOMImpl.java,v 1.18 2001/08/08 10:57:05 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -2410,7 +2410,7 @@
                else {
                    handler.startElement(name);
                }
  -             handler.endElement(name);
  +             return(name);
            }
            else {                  // attribute
                handler.attribute(name, makeStringValue(node));
  
  
  

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

Reply via email to