erdemolkun / plist

Automatically exported from code.google.com/p/plist
0 stars 0 forks source link

Use StringBuffer or StringBuilder instead ""+ #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
This is not a Defect is an enhancement

Original comment by teresaj...@gmail.com on 27 May 2011 at 1:34

GoogleCodeExporter commented 9 years ago
That's a simple change, I'll do it.

Original comment by daniel.dreibrodt on 1 Jul 2011 at 7:32

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago

Original comment by daniel.dreibrodt on 1 Jul 2011 at 8:37

GoogleCodeExporter commented 9 years ago

Original comment by daniel.dreibrodt on 25 Sep 2014 at 5:52