| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 patch class Expando<T> { | 5 patch class Expando<T> { |
| 6 /* patch */ Expando([this.name]) : _data = new List(); | 6 /* patch */ Expando([this.name]) : _data = new List(); |
| 7 | 7 |
| 8 /* patch */ T operator[](Object object) { | 8 /* patch */ T operator[](Object object) { |
| 9 _checkType(object); | 9 _checkType(object); |
| 10 var doCompact = false; | 10 var doCompact = false; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 } | 42 } |
| 43 if (i !== _data.length && value == null) { | 43 if (i !== _data.length && value == null) { |
| 44 doCompact = true; | 44 doCompact = true; |
| 45 _data[i] = null; | 45 _data[i] = null; |
| 46 } else if (i !== _data.length) { | 46 } else if (i !== _data.length) { |
| 47 _data[i].value = value; | 47 _data[i].value = value; |
| 48 } else { | 48 } else { |
| 49 _data.add(new _WeakProperty(object, value)); | 49 _data.add(new _WeakProperty(object, value)); |
| 50 } | 50 } |
| 51 if (doCompact) { | 51 if (doCompact) { |
| 52 _data = _data.where((e) => (e != null)); | 52 _data = _data.where((e) => (e != null)).toList(); |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 static _checkType(object) { | 56 static _checkType(object) { |
| 57 if (object == null) { | 57 if (object == null) { |
| 58 throw new NullPointerException(); | 58 throw new NullPointerException(); |
| 59 } | 59 } |
| 60 if (object is bool || object is num || object is String) { | 60 if (object is bool || object is num || object is String) { |
| 61 throw new ArgumentError(object); | 61 throw new ArgumentError(object); |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 List _data; | 65 List _data; |
| 66 } | 66 } |
| OLD | NEW |