More efficient memory usage when processing repo index

This commit is contained in:
Ciaran Gultnieks 2012-09-12 00:02:27 +01:00
parent 905af06124
commit 64c8ed5507

View File

@ -59,7 +59,7 @@ public class RepoXMLHandler extends DefaultHandler {
private DB.App curapp = null; private DB.App curapp = null;
private DB.Apk curapk = null; private DB.Apk curapk = null;
private String curchars = null; private StringBuilder curchars = new StringBuilder();
private String pubkey; private String pubkey;
private String hashType; private String hashType;
@ -74,16 +74,8 @@ public class RepoXMLHandler extends DefaultHandler {
} }
@Override @Override
public void characters(char[] ch, int start, int length) public void characters(char[] ch, int start, int length) {
throws SAXException { curchars.append(ch, start, length);
super.characters(ch, start, length);
String str = new String(ch).substring(start, start + length);
if (curchars == null)
curchars = str;
else
curchars += str;
} }
@Override @Override
@ -92,7 +84,7 @@ public class RepoXMLHandler extends DefaultHandler {
super.endElement(uri, localName, qName); super.endElement(uri, localName, qName);
String curel = localName; String curel = localName;
String str = curchars; String str = curchars.toString();
if (str != null) { if (str != null) {
str = str.trim(); str = str.trim();
} }
@ -243,7 +235,7 @@ public class RepoXMLHandler extends DefaultHandler {
} else if (localName == "hash" && curapk != null) { } else if (localName == "hash" && curapk != null) {
hashType = attributes.getValue("", "type"); hashType = attributes.getValue("", "type");
} }
curchars = null; curchars.setLength(0);
} }
private void getIcon(DB.App app) { private void getIcon(DB.App app) {