Author: cbrisson
Date: Thu Jul 21 20:52:39 2016
New Revision: 1753736

URL: http://svn.apache.org/viewvc?rev=1753736&view=rev
Log:
[engine] avoid useless string calculation in ASTStringLiteral - fixes 
VELOCITY-833 (thanks to Jarkko Viinamäki)

Modified:
    
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java

Modified: 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java?rev=1753736&r1=1753735&r2=1753736&view=diff
==============================================================================
--- 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
 (original)
+++ 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
 Thu Jul 21 20:52:39 2016
@@ -47,8 +47,6 @@ public class ASTStringLiteral extends Si
 
     private String image = "";
 
-    private String interpolateimage = "";
-
     /** true if the string contains a line comment (##) */
     private boolean containsLineComment;
 
@@ -121,38 +119,39 @@ public class ASTStringLiteral extends Si
             image = replaceQuotes(image, img.charAt(0));
         }
 
-        /**
-         * note. A kludge on a kludge. The first part, Geir calls this the
-         * dreaded <MORE> kludge. Basically, the use of the <MORE> token eats
-         * the last character of an interpolated string. EXCEPT when a line
-         * comment (##) is in the string this isn't an issue.
-         *
-         * So, to solve this we look for a line comment. If it isn't found we
-         * add a space here and remove it later.
-         */
-
-        /**
-         * Note - this should really use a regexp to look for [^\]## but
-         * apparently escaping of line comments isn't working right now anyway.
-         */
-        containsLineComment = (image.indexOf("##") != -1);
-
-        /*
-         * if appropriate, tack a space on the end (dreaded <MORE> kludge)
-         */
-
-        if (!containsLineComment)
-        {
-            interpolateimage = image + " ";
-        }
-        else
-        {
-            interpolateimage = image;
-        }
-
         if (interpolate)
         {
             /*
+             * if appropriate, tack a space on the end (dreaded <MORE> kludge)
+             */
+                
+                   String interpolateimage;
+                       
+               /**
+             * Note - this should really use a regexp to look for [^\]## but
+             * apparently escaping of line comments isn't working right now 
anyway.
+             */
+            containsLineComment = (image.indexOf("##") != -1);
+
+            /**
+             * note. A kludge on a kludge. The first part, Geir calls this the
+             * dreaded <MORE> kludge. Basically, the use of the <MORE> token 
eats
+             * the last character of an interpolated string. EXCEPT when a line
+             * comment (##) is in the string this isn't an issue.
+             *
+             * So, to solve this we look for a line comment. If it isn't found 
we
+             * add a space here and remove it later.
+             */
+            if (!containsLineComment)
+            {
+                interpolateimage = image + " ";
+            }
+            else
+            {
+                interpolateimage = image;
+            }
+
+            /*
              * now parse and init the nodeTree
              */
             StringReader br = new StringReader(interpolateimage);


Reply via email to