Add optional separator argument to StringBuffer.addAll() #9115
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
closed-duplicate
Closed in favor of an existing report
library-core
type-enhancement
A request for a change that isn't a bug
Consider:
writeFunctionCall(StringBuffer buffer, String name, Iterable args) {
buffer.write(name);
buffer.write("(");
buffer.write(args.join(", ")); // <--
buffer.write(")");
}
On the marked line, we're building up an intermediate string only to add it back to the StringBuffer. That's some wasted allocations.
Maybe a cleaner solution is to add an optional separator argument to StringBuffer.writeAll():
writeFunctionCall(StringBuffer buffer, String name, Iterable args) {
buffer.write(name);
buffer.write("(");
buffer.writeAll(args, ", ");
buffer.write(")");
}
The text was updated successfully, but these errors were encountered: