Title: UnicodeEncoder.encode() slow?

Hi,

I am running some performance tests against our MyFaces app. I noticed the following method could be quicker:

UnicodeEncoder.encode()

The HtmlResponseWriterImpl calls this method for all response.write(String) calls - so it's used a lot!

Most of the components we have created for use with MyFaces output some quite long strings to this write.out() method, so the declaration:

        StringBuffer sb = new StringBuffer();

in the method:

        public static String encode (String string, boolean encodeNewline, boolean encodeSubsequentBlanksToNbsp) {…}

is therefore inefficient. Would is possible for it to be changed to something better like this:

        StringBuffer sb = new StringBuffer(string.length() + 4);

Or even better, change the code to create the StringBuffer on demand when it meets the first character that requires encoding?

Thanks!

Kev
--
+44 (0)1628 513624
[EMAIL PROTECTED]

Reply via email to