Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Unified Diff: sdk/lib/core/string_buffer.dart

Issue 13008021: Add optional writeAll separator argument. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/code_buffer.dart ('k') | sdk/lib/core/string_sink.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/string_buffer.dart
diff --git a/sdk/lib/core/string_buffer.dart b/sdk/lib/core/string_buffer.dart
index 50bb51c4249c67031d4d2ce6bb674eac1a8d1c2c..45462195b861da856f28fd337bef1557b50ce878 100644
--- a/sdk/lib/core/string_buffer.dart
+++ b/sdk/lib/core/string_buffer.dart
@@ -29,8 +29,16 @@ class StringBuffer implements StringSink {
/// Adds the string representation of [charCode] to the buffer.
external void writeCharCode(int charCode);
- void writeAll(Iterable objects) {
- for (Object obj in objects) write(obj);
+ void writeAll(Iterable objects, [String separator = ""]) {
+ bool isFirst = true;
+ for (Object obj in objects) {
+ if (isFirst) {
+ isFirst = false;
+ } else {
+ if (separator != "") write(separator);
sra1 2013/03/22 21:19:46 Can we avoid this repeated test in the loop? Or at
floitsch 2013/03/26 18:30:23 Done.
Lasse Reichstein Nielsen 2013/04/03 10:35:52 If speed is of the essence, I'd prefer: void writ
floitsch 2013/04/04 22:36:36 I didn't use Stephen's suggestion but had a code t
+ }
+ write(obj);
+ }
}
void writeln([Object obj = ""]) {
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/code_buffer.dart ('k') | sdk/lib/core/string_sink.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698