erdemolkun / plist

Automatically exported from code.google.com/p/plist

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use StringBuffer or StringBuilder instead ""+

GoogleCodeExporter opened this issue · comments

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

This is not a Defect is an enhancement

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

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
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

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

  • Changed state: Fixed

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

  • Changed state: Verified