DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23924>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23924 Enhanced performance for TagUtils.filter() Summary: Enhanced performance for TagUtils.filter() Product: Struts Version: Nightly Build Platform: All OS/Version: All Status: NEW Severity: Enhancement Priority: Other Component: Custom Tags AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] 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! --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]