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

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

Issue 17578002: pkg/serialization: add format param to Serialization.read method (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: A few more tweaks Created 7 years, 6 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 927f3167673d307132ee2e17f48292f706384a51..fd21e9943e380993ff1e72404ad4c622a1dafa28 100644
--- a/pkg/serialization/lib/src/basic_rule.dart
+++ b/pkg/serialization/lib/src/basic_rule.dart
@@ -442,10 +442,10 @@ class _FieldList extends IterableBase<_Field> {
* know if they are constructor fields or not, but we need to keep this
* information here because the order matters.
*/
- List _constructorFields = const [];
+ final List<_Field> _constructorFields = <_Field>[];
/** The list of fields to exclude if we are computing the list ourselves. */
- List<Symbol> _excludedFieldNames = const [];
+ final List<Symbol> _excludedFieldNames = <Symbol>[];
/** The mirror we will use to compute the fields. */
final ClassMirror mirror;
@@ -464,7 +464,7 @@ class _FieldList extends IterableBase<_Field> {
/** Set the fields to be used in the constructor. */
set constructorFields(List fieldNames) {
if (fieldNames == null || fieldNames.isEmpty) return;
- _constructorFields = [];
+ _constructorFields.clear();
for (var each in fieldNames) {
var symbol = _asSymbol(each);
var name = _Field._isReallyAField(symbol, this) ? symbol : each;
@@ -476,8 +476,10 @@ class _FieldList extends IterableBase<_Field> {
}
/** Set the fields that aren't used in the constructor. */
- set regular(List<String> fields) {
- if (fields == null) return;
+ void set regular(List<String> fields) {
+ if (fields == null) {
Alan Knight 2013/06/26 19:26:29 As above for a guard clause.
+ return;
+ }
_shouldFigureOutFields = false;
addAllByName(fields);
}
@@ -485,22 +487,26 @@ class _FieldList extends IterableBase<_Field> {
/** Set the fields to be excluded. This is mutually exclusive with setting
* the regular fields.
*/
- set exclude(List<String> fields) {
+ void set exclude(List<String> fields) {
// TODO(alanknight): This isn't well tested.
- if (fields == null || fields.isEmpty) return;
+ if (fields == null || fields.isEmpty) {
+ return;
+ }
if (allFields.length > _constructorFields.length) {
throw "You can't specify both excludeFields and regular fields";
}
- _excludedFieldNames = fields.map((x) => new Symbol(x)).toList();
+ _excludedFieldNames.clear();
+ _excludedFieldNames.addAll(fields.map((x) => new Symbol(x)));
}
int get length => allFields.length;
/** Add all the fields which aren't on the exclude list. */
void addAllNotExplicitlyExcluded(Iterable<String> aCollection) {
- if (aCollection == null) return;
- var names = aCollection;
- names = names.where((x) => !_excludedFieldNames.contains(x));
+ if (aCollection == null) {
+ return;
+ }
+ var names = aCollection.where((x) => !_excludedFieldNames.contains(x));
addAllByName(names);
}

Powered by Google App Engine
This is Rietveld 408576698