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

Unified Diff: runtime/lib/string_buffer_patch.dart

Issue 12218086: 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
Index: runtime/lib/string_buffer_patch.dart
diff --git a/runtime/lib/string_buffer_patch.dart b/runtime/lib/string_buffer_patch.dart
index 841fc4f884602dc757f697784a1615af28925f43..04aded78a7c79744012e1c3633c9f38f3592e5f5 100644
--- a/runtime/lib/string_buffer_patch.dart
+++ b/runtime/lib/string_buffer_patch.dart
@@ -2,58 +2,26 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-patch /* abstract */ class StringBuffer {
- /* patch */ factory StringBuffer([Object content = ""])
- => new _StringBufferImpl(content);
-}
-
-class _StringBufferImpl implements StringBuffer {
-
+patch class StringBuffer {
List<String> _buffer;
int _length;
- /// Creates the string buffer with an initial content.
- _StringBufferImpl(Object content) {
- clear();
- add(content);
- }
-
- /// Returns the length of the buffer.
- int get length => _length;
-
- bool get isEmpty => _length == 0;
+ /* patch */ int get length => _length;
/// Adds [obj] to the buffer.
- void add(Object obj) {
- // TODO(srdjan): The following four lines could be replaced by
- // '$obj', but apparently this is too slow on the Dart VM.
- String str = obj.toString();
- if (str is !String) {
- throw new ArgumentError('toString() did not return a string');
- }
- if (str.isEmpty) return;
+ /* patch */ void _write(String str) {
_buffer.add(str);
_length += str.length;
}
- /// Adds all items in [objects] to the buffer.
- void addAll(Iterable objects) {
- for (Object obj in objects) add(obj);
- }
-
- /// Adds the string representation of [charCode] to the buffer.
- void addCharCode(int charCode) {
- add(new String.fromCharCodes([charCode]));
- }
-
/// Clears the string buffer.
- void clear() {
+ /* patch */ void clear() {
_buffer = new List<String>();
_length = 0;
}
/// Returns the contents of buffer as a concatenated string.
- String toString() {
+ /* patch */ String toString() {
if (_buffer.length == 0) return "";
if (_buffer.length == 1) return _buffer[0];
String result = Strings.concatAll(_buffer);
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/lib/core_patch.dart » ('j') | sdk/lib/core/string_buffer.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698