You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2004/07/23 03:52:33 UTC

DO NOT REPLY [Bug 23924] - Enhanced performance for TagUtils.filter()

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.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://issues.apache.org/bugzilla/show_bug.cgi?id=23924

Enhanced performance for TagUtils.filter()





------- Additional Comments From niallp@apache.org  2004-07-23 01:52 -------
Sean,

I only see two additional objects being allocated (rather than three) - the 
StringBuffer and the char[] copy of the String. Seems to me that copying the 
String to a char[] is unnecessary and could be replaced using the String.charAt
(index) function - so it would look like this:

        StringBuffer result = new StringBuffer(value.length() + 50);

        for (int i = 0; i < value.length(); i++) {
            switch (value.charAt(i)) {
                case '<':
                    result.append("&lt;");
                    break;
                case '>':
                    result.append("&gt;");
                    break;
                case '&':
                    result.append("&amp;");
                    break;
                case '"':
                    result.append("&quot;");
                    break;
                case '\'':
                    result.append("&#39;");
                    break;
                default:
                    result.append(value.charAt(i));
            }

I agree with Steve, better to keep this simple - any objections to me applying 
the above change and closing this bug?

Niall

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