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

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

Issue 12300012: Revert "Add StringSink and update StringBuffer." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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/lib/js_helper.dart ('k') | sdk/lib/core/core.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/lib/string_helper.dart
diff --git a/sdk/lib/_internal/compiler/implementation/lib/string_helper.dart b/sdk/lib/_internal/compiler/implementation/lib/string_helper.dart
index 974902831e51dffbe396216b003b5f9992c0069c..e7fbcb0fe7f784f04cc1c8d29efcbdda70ab9647 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/string_helper.dart
+++ b/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 | « sdk/lib/_internal/compiler/implementation/lib/js_helper.dart ('k') | sdk/lib/core/core.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698