You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2003/07/09 23:49:22 UTC
DO NOT REPLY [Bug 21452] New: -
Writing to UTF-8 can be faster by not using s.charAt(i) when looping through chars in the input String
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=21452>.
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=21452
Writing to UTF-8 can be faster by not using s.charAt(i) when looping through chars in the input String
Summary: Writing to UTF-8 can be faster by not using s.charAt(i)
when looping through chars in the input String
Product: XalanJ2
Version: CurrentCVS
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: Other
Component: org.apache.xalan.serialize
AssignedTo: xalan-dev@xml.apache.org
ReportedBy: minchau@ca.ibm.com
WriterToUTF8Buffered loops through characters like this in the input String s:
int len = s.length();
for (int i =0 ; i < len ; i++)
{
char c = s.charAt(i);
// ... process the character
}
Much faster is:
s.getChars(0,len,charArray,0);
for (int i=0; i < len ; i++)
{
char c = charArray[i];
// ... process the character
}
WriterToUTF8 could also run quicker by using an internal array of bytes to
accumulate bytes. At least one call on WriterToUTF8 could result in one call to
the underlying OutputStream rather than upto 3*N calls where N is the number of
input characters.