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

Unified Diff: dart/sdk/lib/_internal/compiler/implementation/lib/string_helper.dart

Issue 11565034: Improve performance of dart2js StringBuffer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Updated to lib_v2 and private libraries. Created 7 years, 11 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
Index: dart/sdk/lib/_internal/compiler/implementation/lib/string_helper.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/lib/string_helper.dart b/dart/sdk/lib/_internal/compiler/implementation/lib/string_helper.dart
index 6e4dccfb2b057aceb67c705d27ef2c06a2dfab45..8ac1fa4b3697dc67316b50acfae212a23fc56f77 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/lib/string_helper.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/lib/string_helper.dart
@@ -202,3 +202,33 @@ stringReplaceFirstUnchecked(receiver, from, to) {
stringJoinUnchecked(array, separator) {
return JS('String', r'#.join(#)', array, separator);
}
+
+class JsStringBuffer implements StringBuffer {
+ String _contents;
+
+ JsStringBuffer(content)
+ : _contents = (content is String) ? content : '$content';
+
+ int get length => _contents.length;
+
+ bool get isEmpty => length == 0;
+
+ void add(Object obj) {
+ _contents = JS('String', '# + #', _contents,
+ (obj is String) ? obj : '$obj');
+ }
+
+ void addAll(Iterable objects) {
+ for (Object obj in objects) add(obj);
+ }
+
+ void addCharCode(int charCode) {
+ add(new String.fromCharCodes([charCode]));
+ }
+
+ void clear() {
+ _contents = "";
+ }
+
+ String toString() => _contents;
+}
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/lib/js_string.dart ('k') | dart/sdk/lib/core/string_buffer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698