* Move almost all uses of StringBuffer to StringBuilder,

for efficiency (thanks Arsene for the suggestion)
This commit is contained in:
zzz
2009-07-01 16:00:43 +00:00
parent 055cd99dde
commit abc23e9a49
198 changed files with 407 additions and 368 deletions

View File

@ -70,12 +70,12 @@ public class HMACSHA256Bench {
long maxLong1 = 0;
byte[] smess = new String("abc").getBytes();
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
for (int x = 0; x < 2*1024; x++) {
buf.append("a");
}
byte[] mmess = buf.toString().getBytes(); // new String("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq").getBytes();
buf = new StringBuffer();
buf = new StringBuilder();
for (int x = 0; x < 10000; x++) {
buf.append("a");
}

View File

@ -133,7 +133,7 @@ public class SHA1HashTest extends TestCase{
}
private final String toHex(final byte[] bytes) {
StringBuffer buf = new StringBuffer(bytes.length * 2);
StringBuilder buf = new StringBuilder(bytes.length * 2);
for (int i = 0; i < bytes.length; i++) {
if ((i & 3) == 0 && i != 0)
buf.append(' ');

View File

@ -57,12 +57,12 @@ public class SHA256Bench {
long maxLong1 = 0;
byte[] smess = new String("abc").getBytes();
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
for (int x = 0; x < 10*1024; x++) {
buf.append("a");
}
byte[] mmess = buf.toString().getBytes(); // new String("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq").getBytes();
buf = new StringBuffer();
buf = new StringBuilder();
for (int x = 0; x < 1000000; x++) {
buf.append("a");
}

View File

@ -13,7 +13,7 @@ public class RateTest extends TestCase {
rate.addData(i * 100, 20);
}
rate.coalesce();
StringBuffer buf = new StringBuffer(1024);
StringBuilder buf = new StringBuilder(1024);
rate.store("rate.test", buf);
byte data[] = buf.toString().getBytes();