Skip to content
Permalink
Browse files
Reset StringBuilder instead of creating new ones
This avoids unneeded garbage, especially during XML parsing.  Replaced
with:

find -name \*.java | xargs sed -i 's/^\( *[^ ]*\) = new StringBuilder();$/\1.setLength(0);/'
  • Loading branch information
gaul committed Aug 6, 2014
1 parent 0b78374 commit add9335c843f989a04faecf3cf971e658c5aebb2
Show file tree
Hide file tree
Showing 31 changed files with 31 additions and 31 deletions.
@@ -80,7 +80,7 @@ else if (currentType == Boolean.class)
} else if (equalsOrSuffix(qName, "UnhealthyThreshold")) {
builder.description(currentOrNull(currentText));
}
currentText = new StringBuilder();
currentText.setLength(0);
}

/**
@@ -30,7 +30,7 @@ public class AvailabilityZonesResultHandler extends ParseSax.HandlerWithResult<S
public void endElement(String uri, String localName, String qName) {
if (qName.equals("member"))
zones.add(currentText.toString().trim());
currentText = new StringBuilder();
currentText.setLength(0);
}

@Override
@@ -38,7 +38,7 @@ public void endElement(String uri, String name, String qName) {
if (qName.equals("DNSName")) {
dnsName = currentOrNull();
}
currentText = new StringBuilder();
currentText.setLength(0);
}

public void characters(char ch[], int start, int length) {
@@ -87,7 +87,7 @@ public void endElement(String uri, String name, String qName) throws SAXExceptio
instanceStateHandler.endElement(uri, name, qName);
}

currentText = new StringBuilder();
currentText.setLength(0);
}

protected void endMember(String uri, String name, String qName) throws SAXException {
@@ -87,7 +87,7 @@ public void endElement(String uri, String name, String qName) throws SAXExceptio
policyHandler.endElement(uri, name, qName);
}

currentText = new StringBuilder();
currentText.setLength(0);
}

protected void endMember(String uri, String name, String qName) throws SAXException {
@@ -87,7 +87,7 @@ public void endElement(String uri, String name, String qName) throws SAXExceptio
policyTypeHandler.endElement(uri, name, qName);
}

currentText = new StringBuilder();
currentText.setLength(0);
}

protected void endMember(String uri, String name, String qName) throws SAXException {
@@ -92,7 +92,7 @@ public void endElement(String uri, String name, String qName) throws SAXExceptio
loadBalancerHandler.endElement(uri, name, qName);
}

currentText = new StringBuilder();
currentText.setLength(0);
}

protected void endMember(String uri, String name, String qName) throws SAXException {
@@ -61,7 +61,7 @@ public void endElement(String uri, String name, String qName) throws SAXExceptio
} else if (equalsOrSuffix(qName, "UnhealthyThreshold")) {
builder.unhealthyThreshold(Integer.parseInt(currentOrNull(currentText)));
}
currentText = new StringBuilder();
currentText.setLength(0);
}

/**
@@ -59,7 +59,7 @@ public void endElement(String uri, String name, String qName) throws SAXExceptio
} else if (equalsOrSuffix(qName, "State")) {
builder.state(currentOrNull(currentText));
}
currentText = new StringBuilder();
currentText.setLength(0);
}

/**
@@ -30,7 +30,7 @@ public class InstancesResultHandler extends ParseSax.HandlerWithResult<Set<Strin
public void endElement(String uri, String localName, String qName) {
if (qName.equals("InstanceId"))
instanceIds.add(currentText.toString().trim());
currentText = new StringBuilder();
currentText.setLength(0);
}

@Override
@@ -79,7 +79,7 @@ public void endElement(String uri, String name, String qName) throws SAXExceptio
} else if (equalsOrSuffix(qName, "SSLCertificateId")) {
builder.SSLCertificateId(currentOrNull(currentText));
}
currentText = new StringBuilder();
currentText.setLength(0);
}

/**
@@ -143,7 +143,7 @@ public void endElement(String uri, String name, String qName) throws SAXExceptio
} else if (inListeners) {
listenerHandler.endElement(uri, name, qName);
}
currentText = new StringBuilder();
currentText.setLength(0);
}

protected void endMember(String uri, String name, String qName) throws SAXException {
@@ -69,7 +69,7 @@ else if (Ints.tryParse(value) != null)
builder.attribute(key, value);
key = null;
}
currentText = new StringBuilder();
currentText.setLength(0);
}

/**
@@ -85,7 +85,7 @@ public void endElement(String uri, String name, String qName) throws SAXExceptio
} else if (inAttributeTypes) {
attributeTypeHandler.endElement(uri, name, qName);
}
currentText = new StringBuilder();
currentText.setLength(0);
}

protected void endMember(String uri, String name, String qName) throws SAXException {
@@ -90,7 +90,7 @@ public void endElement(String uri, String name, String qName) {
builder.createDate(dateService.iso8601DateParse(currentOrNull(currentText)));
}
}
currentText = new StringBuilder();
currentText.setLength(0);
}

@Override
@@ -86,7 +86,7 @@ public void endElement(String uri, String name, String qName) {
afterMarker = currentOrNull(currentText);
}

currentText = new StringBuilder();
currentText.setLength(0);
}

@Override
@@ -63,7 +63,7 @@ public void endElement(String uri, String name, String qName) {
} else if (qName.equals("Marker")) {
afterMarker = currentOrNull(currentText);
}
currentText = new StringBuilder();
currentText.setLength(0);
}

@Override
@@ -79,7 +79,7 @@ public void endElement(String uri, String name, String qName) {
afterMarker = currentOrNull(currentText);
}

currentText = new StringBuilder();
currentText.setLength(0);
}

@Override
@@ -79,7 +79,7 @@ public void endElement(String uri, String name, String qName) {
afterMarker = currentOrNull(currentText);
}

currentText = new StringBuilder();
currentText.setLength(0);
}

@Override
@@ -53,7 +53,7 @@ public void endElement(String uri, String name, String qName) {
} else if (qName.equals("PolicyDocument")) {
builder.document(urlDecode(currentOrNull(currentText)));
}
currentText = new StringBuilder();
currentText.setLength(0);
}

@Override
@@ -73,7 +73,7 @@ public void endElement(String uri, String name, String qName) {
builder.createDate(dateService.iso8601DateParse(currentOrNull(currentText)));
}
}
currentText = new StringBuilder();
currentText.setLength(0);
}

@Override
@@ -65,7 +65,7 @@ public void endElement(String uri, String name, String qName) {
} else if (qName.equals("CreateDate")) {
builder.createDate(dateService.iso8601SecondsDateParse(currentOrNull(currentText)));
}
currentText = new StringBuilder();
currentText.setLength(0);
}

@Override
@@ -87,7 +87,7 @@ public void endElement(String uri, String name, String qName) throws SAXExceptio
instanceHandler.endElement(uri, name, qName);
}

currentText = new StringBuilder();
currentText.setLength(0);
}

/**
@@ -85,7 +85,7 @@ public void endElement(String uri, String name, String qName) throws SAXExceptio
} else if (inSecurityGroups) {
securityGroupHander.endElement(uri, name, qName);
}
currentText = new StringBuilder();
currentText.setLength(0);
}

/**
@@ -85,7 +85,7 @@ public void endElement(String uri, String name, String qName) throws SAXExceptio
} else if (inSubnetGroups) {
subnetGroupHander.endElement(uri, name, qName);
}
currentText = new StringBuilder();
currentText.setLength(0);
}

/**
@@ -62,7 +62,7 @@ public void endElement(String uri, String name, String qName) throws SAXExceptio
builder.rawStatus(rawStatus);
builder.status(Status.fromValue(rawStatus));
}
currentText = new StringBuilder();
currentText.setLength(0);
}

/**
@@ -58,7 +58,7 @@ public void endElement(String uri, String name, String qName) throws SAXExceptio
builder.rawStatus(rawStatus);
builder.status(Status.fromValue(rawStatus));
}
currentText = new StringBuilder();
currentText.setLength(0);
}

/**
@@ -142,7 +142,7 @@ public void endElement(String uri, String name, String qName) throws SAXExceptio
} else if (equalsOrSuffix(qName, "MasterUsername")) {
builder.masterUsername(currentOrNull(currentText));
}
currentText = new StringBuilder();
currentText.setLength(0);
}

/**
@@ -102,7 +102,7 @@ public void endElement(String uri, String name, String qName) throws SAXExceptio
} else if (inIPRanges) {
ipRangeHandler.endElement(uri, name, qName);
}
currentText = new StringBuilder();
currentText.setLength(0);
}

/**
@@ -89,7 +89,7 @@ public void endElement(String uri, String name, String qName) throws SAXExceptio
} else if (inSubnets) {
subnetHandler.endElement(uri, name, qName);
}
currentText = new StringBuilder();
currentText.setLength(0);
}

/**
@@ -57,7 +57,7 @@ public void endElement(String uri, String name, String qName) throws SAXExceptio
} else if (equalsOrSuffix(qName, "SubnetStatus")) {
builder.status(currentOrNull(currentText));
}
currentText = new StringBuilder();
currentText.setLength(0);
}

/**

0 comments on commit add9335

Please sign in to comment.