[ 
https://issues.apache.org/jira/browse/VELOCITY-664?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12660792#action_12660792
 ] 

Jarkko Viinamäki commented on VELOCITY-664:
-------------------------------------------

Hmm now I see this code in the trunk:

    public Object init( InternalContextAdapter context, Object data)
    throws TemplateInitException
    {
        // 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;        
    }

The // comment does not make sense anymore, there is one needless call to 
getFirstToken() and I don't see where you null out the token. And if the token 
is nulled, I think we need to override literal() because that method will break 
if the first token is null.

Are there situations where some AST nodes are actually initialized more than 
once?

> Unnecessary double storing of template text
> -------------------------------------------
>
>                 Key: VELOCITY-664
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-664
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>            Reporter: Byron Foster
>
> ASTText makes a copy of the token image and uses the copy to render.  This 
> means that ASTText keeps two copies of the text.  In the majority of cases 
> ASTText can use the token image.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to