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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]