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

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

Issue 18837002: Move toString() to collection classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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: sdk/lib/collection/maps.dart
diff --git a/sdk/lib/collection/maps.dart b/sdk/lib/collection/maps.dart
index 303008cc6950a815089473c7b0f4e181b89cda13..d54177e4ca36123131ba4c2ace8a95b934685399 100644
--- a/sdk/lib/collection/maps.dart
+++ b/sdk/lib/collection/maps.dart
@@ -60,6 +60,8 @@ class Maps {
static bool isNotEmpty(Map map) => map.keys.isNotEmpty;
+ static List _toStringList = new List();
floitsch 2013/07/08 12:00:50 add comment.
zarah 2013/07/08 14:35:15 Done.
+
/**
* Returns a string representing the specified map. The returned string
* looks like this: [:'{key0: value0, key1: value1, ... keyN: valueN}':].
@@ -76,7 +78,29 @@ class Maps {
* A typical implementation of a map's [toString] method will
* simply return the results of this method applied to the collection.
*/
- static String mapToString(Map m) => ToString.mapToString(m);
+ static String mapToString(Map m) {
+ for(int i = 0; i < _toStringList.length; i++) {
floitsch 2013/07/08 12:00:50 Same comments as for the other toString methods. (
zarah 2013/07/08 14:35:15 Done.
+ if(identical(_toStringList[i], m))
+ return '{...}';
+ }
+
+ _toStringList.add(m);
+ var result = new StringBuffer();
+ result.write('{');
+ bool first = true;
+ m.forEach((k, v) {
+ if(!first) {
+ result.write(', ');
+ }
+ first = false;
+ result.write(k);
+ result.write(': ');
+ result.write(v);
+ });
+ result.write('}');
+ _toStringList.remove(m);
+ return result.toString();
+ }
static _id(x) => x;

Powered by Google App Engine
This is Rietveld 408576698