zongaro     2004/09/24 15:18:57

  Modified:    java/src/org/apache/xalan/xsltc/compiler Variable.java
  Log:
  Skip translation for any unreferenced variables.
  
  Patch reviewed by Christine Li ([EMAIL PROTECTED]).
  
  Revision  Changes    Path
  1.28      +11 -17    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Variable.java
  
  Index: Variable.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Variable.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- Variable.java     24 Feb 2004 02:58:42 -0000      1.27
  +++ Variable.java     24 Sep 2004 22:18:56 -0000      1.28
  @@ -36,13 +36,6 @@
   import org.apache.xalan.xsltc.compiler.util.Type;
   import org.apache.xalan.xsltc.compiler.util.TypeCheckError;
   
  -/**
  - * @author Jacek Ambroziak
  - * @author Santiago Pericas-Geertsen
  - * @author Morten Jorgensen
  - * @author Erwin Bolwidt <[EMAIL PROTECTED]>
  - * @author John Howard <[EMAIL PROTECTED]>
  - */
   final class Variable extends VariableBase {
   
       public int getIndex() {
  @@ -148,25 +141,26 @@
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
   
  -     final String name = getEscapedName();
  +        // Don't generate code for unreferenced variables
  +        if (_refs.isEmpty()) {
  +            _ignore = true;
  +        }
   
        // Make sure that a variable instance is only compiled once
        if (_ignore) return;
        _ignore = true;
   
  +     final String name = getEscapedName();
  +
        if (isLocal()) {
            // Compile variable value computation
            translateValue(classGen, methodGen);
   
            // Add a new local variable and store value
  -         if (_refs.isEmpty()) { // Remove it if nobody uses the value
  -             il.append(_type.POP());
  -             _local = null;
  -         }
  -         else {                 // Store in local var slot if referenced
  -             if (_local == null) mapRegister(methodGen);
  -             il.append(_type.STORE(_local.getIndex()));
  -         }
  +         if (_local == null) {
  +                mapRegister(methodGen);
  +            }
  +         il.append(_type.STORE(_local.getIndex()));
        }
        else {
            String signature = _type.toSignature();
  
  
  

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

Reply via email to