You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by he...@apache.org on 2005/10/01 13:16:21 UTC
svn commit: r292955 -
/jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java
Author: henning
Date: Sat Oct 1 04:16:17 2005
New Revision: 292955
URL: http://svn.apache.org/viewcvs?rev=292955&view=rev
Log:
Removing a String concatenation in a loop, thus improving a possible
StringBuffer.append(StringBuffer) situation. Defuse and comment it.
(String concat found by Findbugs)
Modified:
jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java
Modified: jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java?rev=292955&r1=292954&r2=292955&view=diff
==============================================================================
--- jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java (original)
+++ jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java Sat Oct 1 04:16:17 2005
@@ -39,10 +39,12 @@
*/
public static String specialText(Token t)
{
- String specialText = "";
+ StringBuffer specialText = new StringBuffer();
if (t.specialToken == null || t.specialToken.image.startsWith("##") )
- return specialText;
+ {
+ return "";
+ }
Token tmp_t = t.specialToken;
@@ -115,12 +117,21 @@
}
}
- specialText += sb.toString();
+ // This is a potential JDK 1.3/JDK 1.4 gotcha. If we remove
+ // the toString() method call, then when compiling under JDK 1.4,
+ // this will be mapped to StringBuffer.append(StringBuffer) and
+ // under JDK 1.3, it will be mapped to StringBuffer.append(Object).
+ // So the JDK 1.4 compiled jar will bomb out under JDK 1.3 with a
+ // MethodNotFound error.
+ //
+ // @todo Once we are JDK 1.4+ only, remove the toString(), make this
+ // loop perform a little bit better.
+ specialText.append(sb.toString());
tmp_t = tmp_t.next;
}
- return specialText;
+ return specialText.toString();
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org