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

Unified Diff: sdk/lib/collection/list.dart

Issue 297053002: Reinstall previous behavior for Set and Queue toString. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 6 years, 7 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/collection/iterable.dart ('k') | sdk/lib/collection/queue.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/collection/list.dart
diff --git a/sdk/lib/collection/list.dart b/sdk/lib/collection/list.dart
index 7669a70a5bba94806fb18257b019807330157ae4..b6e1a11b66e2882ebfc6701a9ecaf54787d7a460 100644
--- a/sdk/lib/collection/list.dart
+++ b/sdk/lib/collection/list.dart
@@ -4,9 +4,6 @@
part of dart.collection;
-/** A reusable set used to identify cyclic lists during toString() calls. */
-Set _toStringVisiting = new HashSet.identity();
-
/**
* Abstract implementation of a list.
*
@@ -22,7 +19,16 @@ Set _toStringVisiting = new HashSet.identity();
* to the growable list, or, preferably, use `DelegatingList` from
* "package:collection/wrappers.dart" instead.
*/
-abstract class ListBase<E> = Object with ListMixin<E>;
+abstract class ListBase<E> extends Object with ListMixin<E> {
+ /**
+ * Convert a `List` to a string as `[each, element, as, string]`.
+ *
+ * Handles circular references where converting one of the elements
+ * to a string ends up converting [list] to a string again.
+ */
+ static String listToString(List list) =>
+ IterableBase.iterableToFullString(list, '[', ']');
+}
/**
* Base implementation of a [List] class.
@@ -501,21 +507,5 @@ abstract class ListMixin<E> implements List<E> {
Iterable<E> get reversed => new ReversedListIterable(this);
- String toString() {
- if (_toStringVisiting.contains(this)) {
- return '[...]';
- }
-
- var result = new StringBuffer();
- try {
- _toStringVisiting.add(this);
- result.write('[');
- result.writeAll(this, ', ');
- result.write(']');
- } finally {
- _toStringVisiting.remove(this);
- }
-
- return result.toString();
- }
+ String toString() => IterableBase.iterableToFullString(this, '[', ']');
}
« no previous file with comments | « sdk/lib/collection/iterable.dart ('k') | sdk/lib/collection/queue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698