Author: byron
Date: Mon Jan  5 07:22:09 2009
New Revision: 731597

URL: http://svn.apache.org/viewvc?rev=731597&view=rev
Log:
VELOCITY-664 Changed ASTText render text to char[] for faster writing

Modified:
    
velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTText.java

Modified: 
velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTText.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTText.java?rev=731597&r1=731596&r2=731597&view=diff
==============================================================================
--- 
velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTText.java
 (original)
+++ 
velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTText.java
 Mon Jan  5 07:22:09 2009
@@ -32,7 +32,7 @@
  */
 public class ASTText extends SimpleNode
 {
-    private String ctext;
+    private char[] ctext = null;
 
     /**
      * @param id
@@ -65,11 +65,15 @@
     public Object init( InternalContextAdapter context, Object data)
     throws TemplateInitException
     {
-        Token t = getFirstToken();
-        // In most cases tokenLiteral() will return back t.image, we want to 
use t.image directly
-        // and not a copy because otherwise this would mean all text nodes are 
stored twice.
-        ctext = NodeUtils.tokenLiteral( t );
-        return data;
+        // In case init gets called more then once.
+        if (ctext == null)
+        {
+            Token t = getFirstToken();
+            // In most cases tokenLiteral() will return back t.image, we want 
to use t.image directly
+            // and not a copy because otherwise this would mean all text nodes 
are stored twice.
+            ctext = NodeUtils.tokenLiteral(getFirstToken()).toCharArray();
+        }
+        return data;        
     }
 
     /**


Reply via email to