Closed
Description
The first block in the following pattern triggers use_string_buffers
but the second block (which uses StringBuffer) is ~7% slower:
const int count = 100000;
void test(String s) { }
void main() {
Stopwatch t = new Stopwatch();
// USING STRING
t.start();
String s = '';
for (int i = 0; i < count; i += 1) {
s = s + '-$i';
test(s);
}
print(t.elapsedMicroseconds);
// USING STRINGBUFFER
t.reset();
StringBuffer b = new StringBuffer();
for (int i = 0; i < count; i += 1) {
b.write('-$i');
test(b.toString());
}
print(t.elapsedMicroseconds);
}