You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by bl...@apache.org on 2001/01/31 16:48:39 UTC
cvs commit: xml-cocoon/src/org/apache/cocoon/selection CodedSelectorFactory.java
bloritsch 01/01/31 07:48:39
Modified: src/org/apache/cocoon Tag: xml-cocoon2 Main.java
Notifier.java
src/org/apache/cocoon/components/language/programming/java
Tag: xml-cocoon2 JavaLanguage.java Javac.java
Jikes.java
src/org/apache/cocoon/matching Tag: xml-cocoon2
BrowserMatcherFactory.java
WildcardURIMatcherFactory.java
src/org/apache/cocoon/selection Tag: xml-cocoon2
CodedSelectorFactory.java
Log:
StringBuffer optimization. Anywhere there was _already_ a StringBuffer, I made sure
that .append() was used instead of plus (+). No new StringBuffers were added.
Revision Changes Path
No revision
No revision
1.1.4.19 +8 -8 xml-cocoon/src/org/apache/cocoon/Attic/Main.java
Index: Main.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Attic/Main.java,v
retrieving revision 1.1.4.18
retrieving revision 1.1.4.19
diff -u -r1.1.4.18 -r1.1.4.19
--- Main.java 2001/01/22 21:56:32 1.1.4.18
+++ Main.java 2001/01/31 15:48:35 1.1.4.19
@@ -48,7 +48,7 @@
* Command line entry point.
*
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.1.4.18 $ $Date: 2001/01/22 21:56:32 $
+ * @version CVS $Revision: 1.1.4.19 $ $Date: 2001/01/31 15:48:35 $
*/
public class Main {
@@ -212,14 +212,14 @@
private static void printUsage() {
String lSep = System.getProperty("line.separator");
StringBuffer msg = new StringBuffer();
- msg.append("------------------------------------------------------------------------ " + lSep);
- msg.append(Cocoon.NAME + " " + Cocoon.VERSION + lSep);
- msg.append("Copyright (c) " + Cocoon.YEAR + " Apache Software Foundation. All rights reserved." + lSep);
- msg.append("------------------------------------------------------------------------ " + lSep + lSep);
- msg.append("Usage: java org.apache.cocoon.Main [options] [targets]" + lSep + lSep);
- msg.append("Options: " + lSep);
+ msg.append("------------------------------------------------------------------------ ").append(lSep);
+ msg.append(Cocoon.NAME).append(" ").append(Cocoon.VERSION).append(lSep);
+ msg.append("Copyright (c) ").append(Cocoon.YEAR).append(" Apache Software Foundation. All rights reserved.").append(lSep);
+ msg.append("------------------------------------------------------------------------ ").append(lSep).append(lSep);
+ msg.append("Usage: java org.apache.cocoon.Main [options] [targets]").append(lSep).append(lSep);
+ msg.append("Options: ").append(lSep);
msg.append(CLUtil.describeOptions(Main.options).toString());
- msg.append("Note: the context directory defaults to '" + Cocoon.DEFAULT_CONTEXT_DIR + "'" + lSep);
+ msg.append("Note: the context directory defaults to '").append(Cocoon.DEFAULT_CONTEXT_DIR + "'").append(lSep);
System.out.println(msg.toString());
System.exit(0);
}
1.1.2.7 +12 -12 xml-cocoon/src/org/apache/cocoon/Attic/Notifier.java
Index: Notifier.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Attic/Notifier.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- Notifier.java 2000/10/12 16:43:11 1.1.2.6
+++ Notifier.java 2001/01/31 15:48:35 1.1.2.7
@@ -32,9 +32,9 @@
*
* @author <a href="mailto:nicolaken@supereva.it">Nicola Ken Barozzi</a> Aisa
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/10/12 16:43:11 $
+ * @version CVS $Revision: 1.1.2.7 $ $Date: 2001/01/31 15:48:35 $
*/
-
+
public class Notifier {
/**
@@ -45,22 +45,22 @@
StringBuffer sb = new StringBuffer();
// FIXME (SM) how can we send the error with the proper content type?
-
+
res.setContentType("text/html");
- sb.append("<html><head><title>" + n.getTitle() + "</title>");
+ sb.append("<html><head><title>").append(n.getTitle()).append("</title>");
sb.append("<STYLE><!--H1{font-family : sans-serif,Arial,Tahoma;color : white;background-color : #0086b2;} ");
sb.append("BODY{font-family : sans-serif,Arial,Tahoma;color : black;background-color : white;} ");
sb.append("B{color : white;background-color : #0086b2;} ");
sb.append("HR{color : #0086b2;} ");
sb.append("--></STYLE> ");
sb.append("</head><body>");
- sb.append("<h1>Cocoon 2 - " + n.getTitle() + "</h1>");
+ sb.append("<h1>Cocoon 2 - ").append(n.getTitle()).append("</h1>");
sb.append("<HR size=\"1\" noshade>");
- sb.append("<p><b>type</b> " + n.getType() + "</p>");
- sb.append("<p><b>message</b> <u>" + n.getMessage() + "</u></p>");
- sb.append("<p><b>description</b> <u>" + n.getDescription() + "</u></p>");
- sb.append("<p><b>sender</b> " + n.getSender() + "</p>");
- sb.append("<p><b>source</b> " + n.getSource() + "</p>");
+ sb.append("<p><b>type</b> ").append(n.getType()).append("</p>");
+ sb.append("<p><b>message</b> <u>").append(n.getMessage()).append("</u></p>");
+ sb.append("<p><b>description</b> <u>").append(n.getDescription()).append("</u></p>");
+ sb.append("<p><b>sender</b> ").append(n.getSender()).append("</p>");
+ sb.append("<p><b>source</b> ").append(n.getSource()).append("</p>");
HashMap extraDescriptions = n.getExtraDescriptions();
Iterator keyIter = extraDescriptions.keySet().iterator();
@@ -68,7 +68,7 @@
while (keyIter.hasNext()) {
String key = (String) keyIter.next();
- sb.append("<p><b>" + key + "</b><pre>" + extraDescriptions.get(key) + "</pre></p>");
+ sb.append("<p><b>").append(key).append("</b><pre>").append(extraDescriptions.get(key)).append("</pre></p>");
}
sb.append("<HR size=\"1\" noshade>");
@@ -86,7 +86,7 @@
final String URI = Cocoon.ERROR_NAMESPACE_URI;
String buf;
-
+
// Start the document
ch.startDocument();
ch.startPrefixMapping(PREFIX, URI);
No revision
No revision
1.1.2.20 +2 -2 xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/JavaLanguage.java
Index: JavaLanguage.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/JavaLanguage.java,v
retrieving revision 1.1.2.19
retrieving revision 1.1.2.20
diff -u -r1.1.2.19 -r1.1.2.20
--- JavaLanguage.java 2001/01/31 05:21:44 1.1.2.19
+++ JavaLanguage.java 2001/01/31 15:48:36 1.1.2.20
@@ -32,7 +32,7 @@
* The Java programming language processor
*
* @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
- * @version CVS $Revision: 1.1.2.19 $ $Date: 2001/01/31 05:21:44 $
+ * @version CVS $Revision: 1.1.2.20 $ $Date: 2001/01/31 15:48:36 $
*/
public class JavaLanguage extends CompiledProgrammingLanguage implements ThreadSafe {
@@ -278,7 +278,7 @@
File[] files = dir.listFiles(new JavaArchiveFilter());
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < files.length; i++) {
- buffer.append(files[i] + File.pathSeparator);
+ buffer.append(files[i]).append(File.pathSeparator);
}
return buffer.toString();
}
1.1.2.11 +5 -5 xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/Javac.java
Index: Javac.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/Javac.java,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -u -r1.1.2.10 -r1.1.2.11
--- Javac.java 2001/01/31 05:21:45 1.1.2.10
+++ Javac.java 2001/01/31 15:48:36 1.1.2.11
@@ -18,7 +18,7 @@
* This class wraps the Sun's Javac Compiler.
*
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
- * @version $Revision: 1.1.2.10 $ $Date: 2001/01/31 05:21:45 $
+ * @version $Revision: 1.1.2.11 $ $Date: 2001/01/31 15:48:36 $
* @since 2.0
*/
@@ -91,11 +91,11 @@
protected List parseModernStream(BufferedReader input) throws IOException {
List errors = null;
String line = null;
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = null;
while (true) {
// cleanup the buffer
- buffer.delete(0, buffer.length());
+ buffer = new StringBuffer(); // this is quicker than clearing it
// each error terminates with the '^' char
do {
@@ -147,11 +147,11 @@
List errors = null;
String line = null;
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = null;
while (true) {
// cleanup the buffer
- buffer.delete(0, buffer.length());
+ buffer = new StringBuffer(); // this is faster than clearing it
// each error has 3 lines
for (int i = 0; i < 3 ; i++) {
1.1.2.9 +3 -3 xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/Jikes.java
Index: Jikes.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/Jikes.java,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- Jikes.java 2000/12/11 15:06:02 1.1.2.8
+++ Jikes.java 2001/01/31 15:48:36 1.1.2.9
@@ -16,7 +16,7 @@
* This class wraps IBM's <i>Jikes</i> Java compiler
* NOTE: inspired by the Apache Jasper implementation.
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
- * @version $Revision: 1.1.2.8 $ $Date: 2000/12/11 15:06:02 $
+ * @version $Revision: 1.1.2.9 $ $Date: 2001/01/31 15:48:36 $
* @since 2.0
*/
@@ -153,11 +153,11 @@
protected List parseStream(BufferedReader input) throws IOException {
List errors = null;
String line = null;
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = null;
while (true) {
// cleanup the buffer
- buffer.delete(0, buffer.length());
+ buffer = new StringBuffer(); // this is faster than clearing it
// first line is not space-starting
if (line == null) line = input.readLine();
No revision
No revision
1.1.2.11 +18 -18 xml-cocoon/src/org/apache/cocoon/matching/Attic/BrowserMatcherFactory.java
Index: BrowserMatcherFactory.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/BrowserMatcherFactory.java,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -u -r1.1.2.10 -r1.1.2.11
--- BrowserMatcherFactory.java 2000/10/30 23:02:44 1.1.2.10
+++ BrowserMatcherFactory.java 2001/01/31 15:48:37 1.1.2.11
@@ -1,11 +1,11 @@
-/*****************************************************************************
- * Copyright (C) The Apache Software Foundation. All rights reserved. *
- * ------------------------------------------------------------------------- *
- * This software is published under the terms of the Apache Software License *
- * version 1.1, a copy of which has been included with this distribution in *
- * the LICENSE file. *
- *****************************************************************************/
-package org.apache.cocoon.matching;
+/*****************************************************************************
+ * Copyright (C) The Apache Software Foundation. All rights reserved. *
+ * ------------------------------------------------------------------------- *
+ * This software is published under the terms of the Apache Software License *
+ * version 1.1, a copy of which has been included with this distribution in *
+ * the LICENSE file. *
+ *****************************************************************************/
+package org.apache.cocoon.matching;
import java.util.Stack;
@@ -16,15 +16,15 @@
import org.apache.avalon.ConfigurationException;
import org.apache.xerces.dom.TreeWalkerImpl;
-
-/**
+
+/**
* This class generates source code which matches a specific browser pattern
* for request URIs
- *
+ *
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
* @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
- * @version CVS $Revision: 1.1.2.10 $ $Date: 2000/10/30 23:02:44 $
- */
+ * @version CVS $Revision: 1.1.2.11 $ $Date: 2001/01/31 15:48:37 $
+ */
public class BrowserMatcherFactory implements org.apache.cocoon.CodeFactory {
@@ -41,22 +41,22 @@
.append(node.getNodeName())
.append(" type=")
.append(node.getNodeType())
- .append(" value="+node.getNodeValue()+"\n");
+ .append(" value=").append(node.getNodeValue()).append("\n");
nm = node.getAttributes();
if (nm != null) {
int i = nm.getLength();
for (int j = 0; j < i; j++) {
nodea = nm.item(j);
- sb.append("name="+nodea.getNodeName())
- .append(" type="+nodea.getNodeType())
- .append(" value="+nodea.getNodeValue()+"\n");
+ sb.append("name=").append(nodea.getNodeName())
+ .append(" type=").append(nodea.getNodeType())
+ .append(" value=").append(nodea.getNodeValue()).append("\n");
}
}
}
return sb.append("*/\nreturn null;").toString();
}
- public String generateClassSource (String prefix, String pattern,
+ public String generateClassSource (String prefix, String pattern,
NodeIterator conf)
throws ConfigurationException {
return "\n// Dummy values\nstatic String " + prefix + "_expr = \"" + pattern + "\";\n";
1.1.2.27 +2 -2 xml-cocoon/src/org/apache/cocoon/matching/Attic/WildcardURIMatcherFactory.java
Index: WildcardURIMatcherFactory.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/WildcardURIMatcherFactory.java,v
retrieving revision 1.1.2.26
retrieving revision 1.1.2.27
diff -u -r1.1.2.26 -r1.1.2.27
--- WildcardURIMatcherFactory.java 2001/01/22 21:56:46 1.1.2.26
+++ WildcardURIMatcherFactory.java 2001/01/31 15:48:38 1.1.2.27
@@ -24,7 +24,7 @@
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
* @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
- * @version CVS $Revision: 1.1.2.26 $ $Date: 2001/01/22 21:56:46 $
+ * @version CVS $Revision: 1.1.2.27 $ $Date: 2001/01/31 15:48:38 $
*/
public class WildcardURIMatcherFactory implements CodeFactory, Loggable {
@@ -83,7 +83,7 @@
try {
this.setPattern (pattern);
- result.append ("\n// wildcard pattern = \"" + pattern + "\"\n\t")
+ result.append ("\n// wildcard pattern = \"").append(pattern).append("\"\n\t")
.append ("static int[] ").append(prefix).append("_expr = {");
int j = sourcePattern.length - 1;
No revision
No revision
1.1.2.6 +2 -2 xml-cocoon/src/org/apache/cocoon/selection/Attic/CodedSelectorFactory.java
Index: CodedSelectorFactory.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/selection/Attic/CodedSelectorFactory.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- CodedSelectorFactory.java 2000/12/10 19:49:52 1.1.2.5
+++ CodedSelectorFactory.java 2001/01/31 15:48:38 1.1.2.6
@@ -18,7 +18,7 @@
* embedded java code within the 'test' clause of the select.
*
* @author <a href="mailto:Marcus.Crafter@osa.de">Marcus Crafter</a>
- * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/12/10 19:49:52 $
+ * @version CVS $Revision: 1.1.2.6 $ $Date: 2001/01/31 15:48:38 $
*/
public class CodedSelectorFactory extends java.lang.Object
implements CodeFactory {
@@ -38,7 +38,7 @@
.append( "_expr = new org.apache.cocoon.selection.helpers.CodedSelectorHelper() {" )
.append( "public boolean evaluate(Map objectModel) {" )
.append( "initialize(objectModel);" )
- .append( "return (" + test + ");" )
+ .append( "return (").append(test).append(");" )
.append( "}" )
.append( "};" );
return sb.toString();