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

Side by Side Diff: sdk/lib/core/string_buffer.dart

Issue 1086043002: dart2js implementation of StringBuffer.writeAll that optimizes better (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: use Duration instead of StringBuffer for pub tests... until we optimize that! Created 5 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.core; 5 part of dart.core;
6 6
7 /** 7 /**
8 * A class for concatenating strings efficiently. 8 * A class for concatenating strings efficiently.
9 * 9 *
10 * Allows for the incremental building of a string using write*() methods. 10 * Allows for the incremental building of a string using write*() methods.
(...skipping 19 matching lines...) Expand all
30 * operation. 30 * operation.
31 */ 31 */
32 bool get isNotEmpty => !isEmpty; 32 bool get isNotEmpty => !isEmpty;
33 33
34 /// Adds the contents of [obj], converted to a string, to the buffer. 34 /// Adds the contents of [obj], converted to a string, to the buffer.
35 external void write(Object obj); 35 external void write(Object obj);
36 36
37 /// Adds the string representation of [charCode] to the buffer. 37 /// Adds the string representation of [charCode] to the buffer.
38 external void writeCharCode(int charCode); 38 external void writeCharCode(int charCode);
39 39
40 void writeAll(Iterable objects, [String separator = ""]) { 40 external void writeAll(Iterable objects, [String separator = ""]);
41 Iterator iterator = objects.iterator;
42 if (!iterator.moveNext()) return;
43 if (separator.isEmpty) {
44 do {
45 write(iterator.current);
46 } while (iterator.moveNext());
47 } else {
48 write(iterator.current);
49 while (iterator.moveNext()) {
50 write(separator);
51 write(iterator.current);
52 }
53 }
54 }
55 41
56 void writeln([Object obj = ""]) { 42 external void writeln([Object obj = ""]);
57 write(obj);
58 write("\n");
59 }
60 43
61 /** 44 /**
62 * Clears the string buffer. 45 * Clears the string buffer.
63 */ 46 */
64 external void clear(); 47 external void clear();
65 48
66 /// Returns the contents of buffer as a concatenated string. 49 /// Returns the contents of buffer as a concatenated string.
67 external String toString(); 50 external String toString();
68 } 51 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/test/dart2js/source_maps_include_core_libs_test.dart ('k') | tests/corelib/string_buffer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698