Commit 5094bbe3 authored by Christian Schudt's avatar Christian Schudt

Replace StringBuffer with StringBuilder (for performance).

And don't use String concatenation within the append() method.
parent cce0b3d0
......@@ -155,7 +155,7 @@ public class FlashCrossDomainHandler extends BasicModule {
* @return the string read from the reader.
*/
protected String read(BufferedReader in) {
StringBuffer buffer = new StringBuffer();
StringBuilder buffer = new StringBuilder();
int codePoint;
boolean stopReading = false;
int invalidCodePoints = 0;
......
......@@ -86,7 +86,7 @@ public class URLUTF8Encoder
*/
public static String encode(String s)
{
StringBuffer sbuf = new StringBuffer();
StringBuilder sbuf = new StringBuilder();
int len = s.length();
for (int i = 0; i < len; i++) {
int ch = s.charAt(i);
......
......@@ -503,7 +503,7 @@ public class FastDateFormat {
}
private static String parseToken(String pattern, int[] indexRef) {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
int i = indexRef[0];
int length = pattern.length();
......
......@@ -300,7 +300,7 @@ public class LocaleUtils {
*/
public static String getTimeZoneName(String zoneID, Locale locale) {
TimeZone zone = TimeZone.getTimeZone(zoneID);
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
// Add in the GMT part to the name. First, figure out the offset.
int offset = zone.getRawOffset();
if (zone.inDaylightTime(new Date()) && zone.useDaylightTime()) {
......
......@@ -1070,13 +1070,13 @@ public class StringUtils {
diff = diff % MS_IN_A_SECOND;
//long numMilliseconds = diff;
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
if (numHours > 0) {
buf.append(numHours + " " + HOURS + ", ");
buf.append(numHours).append(' ').append(HOURS).append(", ");
}
if (numMinutes > 0) {
buf.append(numMinutes + " " + MINUTES);
buf.append(numMinutes).append(' ').append(MINUTES);
}
//buf.append(numSeconds + " " + SECONDS);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment