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

Unified Diff: pkg/serialization/lib/src/basic_rule.dart

Issue 12328104: Change new List(n) to return fixed length list. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to head. 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: pkg/serialization/lib/src/basic_rule.dart
diff --git a/pkg/serialization/lib/src/basic_rule.dart b/pkg/serialization/lib/src/basic_rule.dart
index 19a8bcab3c63f059edae35a827df76855c1c1d04..fe9428f2f347ab0301e8d5c6dc15e5d7874c44f7 100644
--- a/pkg/serialization/lib/src/basic_rule.dart
+++ b/pkg/serialization/lib/src/basic_rule.dart
@@ -130,12 +130,19 @@ class BasicRule extends SerializationRule {
useMaps = false;
}
- /** Create either a list or a map to hold the object's state, depending
+ /**
+ * Create either a list or a map to hold the object's state, depending
* on the [useMaps] variable. If using a Map, we wrap it in order to keep
* the protocol compatible. See [configureForLists]/[configureForMaps].
+ *
+ * If a list is returned, it is growable.
*/
- createStateHolder() =>
- useMaps ? new _MapWrapper(fields.contents) : new List(fields.length);
+ createStateHolder() {
+ if (useMaps) return new _MapWrapper(fields.contents);
+ List list = [];
+ list.length = fields.length;
+ return list;
+ }
/**
* Wrap the state if it's passed in as a map, and if the keys are references,

Powered by Google App Engine
This is Rietveld 408576698