You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "David Evans (JIRA)" <ji...@apache.org> on 2006/04/25 20:48:45 UTC

[jira] Closed: (STR-1798) Enhanced performance for TagUtils.filter()

     [ http://issues.apache.org/struts/browse/STR-1798?page=all ]
     
David Evans closed STR-1798:
----------------------------

    Resolution: Fixed

> Enhanced performance for TagUtils.filter()
> ------------------------------------------
>
>          Key: STR-1798
>          URL: http://issues.apache.org/struts/browse/STR-1798
>      Project: Struts Action 1
>         Type: Improvement

>   Components: Taglibs
>     Versions: Nightly Build
>  Environment: Operating System: All
> Platform: All
>     Reporter: Sean Owen
>     Assignee: David Evans
>     Priority: Minor
>      Fix For: 1.2 Family
>  Attachments: TagUtils.patchfile.txt, TestTagUtils.java, build-tests.xml.patchfile.txt
>
> The TagUtils.filter() method, which replaces certain characters with
> corresponding XML entity references, can be easily enhanced to run much faster
> and require less memory.
> To summarize it can be made faster in two ways:
> * Instead of building up the escape string character by character, with a call
> to StringBuffer.append() for each character, it can be rewritten to copy chunks
> of input at a time, avoiding many method calls, which is most of the overhead of
> this method.
> * In fact the method does not even need to allocate a StringBuffer until it
> knows that some character in the input must be escaped. In the common case where
> the input has no such characters, this avoids allocating any additional memory
> at all.
> Performance improvements is large when the string has no characters to be
> escaped -- 1000% or more on the small and medium-sized strings I tested on. It
> offers more modest improvement when the string has some escapable characters --
> 50-100% on small and medium-sized strings. It is only slower in contrived cases
> like "<<<<>>>>".
> While it is a small method, it is called many times by the Struts framework.
> This is an easy and reliable change to squeeze out a little better performance
> in time and memory for all applications.
> Note that I created a JUnit test for this change (included) in order to verify
> that the new method works as well as the current one.
> Please find attached files which implement this enhancement:
> * TagUtils.patchfile.txt
>   Patch against the 10/19/2003 nightly build to implement the change to filter()
> * TestTagUtils
>   A new JUnit test case covering the filter() method
> * build-test.xml.patchfile.txt
>   Patch against the 10/19/2003 build-test.xml file to invoke TestTagUtils
> I posted this change to the list once before with no result -- I hope this even
> better version, with unit test this time, can be considered for inclusion in
> Struts -- thanks!

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/struts/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org