Use StringBuffer or StringBuilder instead ""+
GoogleCodeExporter opened this issue · comments
Google Code Exporter commented
I use the library for generating XML. The addition of strings makes XML
generation is very slow. Why not use StringBuffer or StringBuilder instead of
adding Strings?
For example:
public void toXML(StringBuffer xml) {
xml.append("<array>");
for (NSObject o : array) {
o.toXML(xml);
}
xml.append("</array>");
}
public String toXMLPropertyList() {
StringBuffer xml = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
xml.append(System.getProperty("line.separator"));
xml.append("<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">");
xml.append(System.getProperty("line.separator"));
xml.append("<plist version=\"1.0\">").append(System.getProperty("line.separator"));
toXML(xml);
xml.append("</plist>");
return xml.toString();
}
Original issue reported on code.google.com by teresaj...@gmail.com
on 27 May 2011 at 1:30
Google Code Exporter commented
This is not a Defect is an enhancement
Original comment by teresaj...@gmail.com
on 27 May 2011 at 1:34
Google Code Exporter commented
That's a simple change, I'll do it.
Original comment by daniel.dreibrodt
on 1 Jul 2011 at 7:32
- Changed state: Accepted
- Added labels: Type-Enhancement
- Removed labels: Type-Defect
Google Code Exporter commented
I will use StringBuilder instead of StringBuffer as this brings even better
performance. Will be fixed in r17.
Original comment by daniel.dreibrodt
on 1 Jul 2011 at 7:49
- Changed state: Started
Google Code Exporter commented
Original comment by daniel.dreibrodt
on 1 Jul 2011 at 8:37
- Changed state: Fixed
Google Code Exporter commented
Original comment by daniel.dreibrodt
on 25 Sep 2014 at 5:52
- Changed state: Verified