* Move almost all uses of StringBuffer to StringBuilder,
for efficiency (thanks Arsene for the suggestion)
This commit is contained in:
@ -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");
|
||||
}
|
||||
|
@ -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(' ');
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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();
|
||||
|
Reference in New Issue
Block a user