You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by GitBox <gi...@apache.org> on 2022/06/13 07:52:14 UTC

[GitHub] [freemarker] GVDV opened a new pull request, #82: replace String by StringBuilder in ElementModel

GVDV opened a new pull request, #82:
URL: https://github.com/apache/freemarker/pull/82

   I had a problem when using Freemarker with xml 's containing large content ( > 600KB)
   The number of nodes were high, more then 10 000 and when using String concatenation as in the following snippet the performance was/is very poor.
   
    _if (nodeType == Node.ELEMENT_NODE) {
                   String msg = "Only elements with no child elements can be processed as text."
                                + "\nThis element with name \""
                                + node.getNodeName()
                                + "\" has a child element named: " + child.getNodeName();
                   throw new TemplateModelException(msg);
               } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
                   result += child.getNodeValue();
               }_
   
   For a xml file of 600kb this took 6 to 11 seconds to process.
   When using a StringBuilder this takes 60 ms.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@freemarker.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [freemarker] ddekany commented on pull request #82: replace String by StringBuilder in ElementModel

Posted by GitBox <gi...@apache.org>.
ddekany commented on PR #82:
URL: https://github.com/apache/freemarker/pull/82#issuecomment-1156754365

   Yeah, that was a quite bad there. Thanks! On the other hand, even if the file is huge, I would expect one big text node, unless there were lot of comments slicing it up.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@freemarker.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [freemarker] ddekany merged pull request #82: replace String by StringBuilder in ElementModel

Posted by GitBox <gi...@apache.org>.
ddekany merged PR #82:
URL: https://github.com/apache/freemarker/pull/82


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@freemarker.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org