tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marcs...@apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/jasper/compiler Compiler.java JspCompiler.java
Date Tue, 01 Jul 2003 20:59:03 GMT
marcsaeg    2003/07/01 13:59:02

  Modified:    src/share/org/apache/jasper/compiler Tag: tomcat_32
                        Compiler.java JspCompiler.java
  Log:
  Avoid multiple calls to isOutDated().
  Avoid multiple string concatenations in getPackageName().
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.19.2.7  +3 -6      jakarta-tomcat/src/share/org/apache/jasper/compiler/Compiler.java
  
  Index: Compiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/Compiler.java,v
  retrieving revision 1.19.2.6
  retrieving revision 1.19.2.7
  diff -u -r1.19.2.6 -r1.19.2.7
  --- Compiler.java	9 Mar 2001 23:35:25 -0000	1.19.2.6
  +++ Compiler.java	1 Jul 2003 20:59:02 -0000	1.19.2.7
  @@ -116,9 +116,6 @@
                             new Object[] { classFileName },
                             Logger.DEBUG);
   
  -	if (!isOutDated())
  -            return false;
  -
   	// Hack to avoid readign the class file every time -
   	// getClassName() is an _expensive_ operation, and it's needed only
   	// if isOutDated() return true. 
  
  
  
  1.14.2.4  +34 -17    jakarta-tomcat/src/share/org/apache/jasper/compiler/JspCompiler.java
  
  Index: JspCompiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspCompiler.java,v
  retrieving revision 1.14.2.3
  retrieving revision 1.14.2.4
  diff -u -r1.14.2.3 -r1.14.2.4
  --- JspCompiler.java	5 Jan 2001 18:07:21 -0000	1.14.2.3
  +++ JspCompiler.java	1 Jul 2003 20:59:02 -0000	1.14.2.4
  @@ -94,11 +94,19 @@
           this.outDated = false;
           setMangler(this);
   
  -	// If the .class file exists and is outdated, compute a new
  -	// class name
  -	if( isOutDated() ) {
  -	    generateNewClassName();
  -	}
  +        ctxt.setServletPackageName(getPackageName());
  +    }
  +
  +    public boolean compile() throws FileNotFoundException, JasperException, Exception 
  +
  +    {
  +        // If the .class file exists and is outdated, compute a new class name
  +        if( isOutDated() ) {
  +            generateNewClassName();
  +            return super.compile();
  +        }
  +
  +        return false;
       }
   
       private void generateNewClassName() {
  @@ -195,6 +203,15 @@
           "try", "void", "volatile", "while" 
       };
   
  +    public static String[] fsKeywords = null;
  +    static{
  +        fsKeywords = new String[keywords.length];
  +        char fs = File.separatorChar;
  +        for(int i=0;i<keywords.length;i++){
  +            fsKeywords[i] = new String(fs + keywords[i]);
  +        }
  +    }
  +
       public final String getPackageName() {
           if( pkgName!=null) return pkgName;
   
  @@ -206,18 +223,18 @@
   	if (indexOfSepChar == -1 || indexOfSepChar == 0)
   	    pkgName = null;
   	else {
  -	    for (int i = 0; i < keywords.length; i++) {
  -		char fs = File.separatorChar;
  -		int index1 = pathName.indexOf(fs + keywords[i]);
  -		int index2 = pathName.indexOf(keywords[i]);
  -		if (index1 == -1 && index2 == -1) continue;
  -		int index = (index2 == -1) ? index1 : index2;
  -		while (index != -1) {
  -		    String tmpathName = pathName.substring (0,index+1) + '%';
  -		    pathName = tmpathName + pathName.substring (index+2);
  -		    index = pathName.indexOf(fs + keywords[i]);
  -		}
  -	    }
  +        char fs = File.separatorChar;
  +        for (int i = 0; i < keywords.length; i++) {
  +            int index1 = pathName.indexOf(fsKeywords[i]);
  +            int index2 = pathName.indexOf(keywords[i]);
  +            if (index1 == -1 && index2 == -1) continue;
  +            int index = (index2 == -1) ? index1 : index2;
  +            while (index != -1) {
  +                String tmpathName = pathName.substring (0,index+1) + '%';
  +                pathName = tmpathName + pathName.substring (index+2);
  +                index = pathName.indexOf(fs + keywords[i]);
  +            }
  +        }
   	    
   	    // XXX fix for paths containing '.'.
   	    // Need to be more elegant here.
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message