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

Side by Side Diff: runtime/lib/expando_patch.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/lib/double_patch.dart ('k') | runtime/lib/function_patch.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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;
11 var result = null; 11 var result = null;
12 for (int i = 0; i < _data.length; ++i) { 12 for (int i = 0; i < _data.length; ++i) {
13 var key = _data[i].key; 13 var key = _data[i].key;
14 if (identical(key, object)) { 14 if (identical(key, object)) {
15 result = _data[i].value; 15 result = _data[i].value;
16 break; 16 break;
17 } 17 }
18 if (key == null) { 18 if (key == null) {
19 doCompact = true; 19 doCompact = true;
20 _data[i] = null; 20 _data[i] = null;
21 } 21 }
22 } 22 }
23 if (doCompact) { 23 if (doCompact) {
24 _data = _data.filter((e) => (e != null)); 24 _data = _data.where((e) => (e != null)).toList();
25 } 25 }
26 return result; 26 return result;
27 } 27 }
28 28
29 /* patch */ void operator[]=(Object object, T value) { 29 /* patch */ void operator[]=(Object object, T value) {
30 _checkType(object); 30 _checkType(object);
31 var doCompact = false; 31 var doCompact = false;
32 int i = 0; 32 int i = 0;
33 for (; i < _data.length; ++i) { 33 for (; i < _data.length; ++i) {
34 var key = _data[i].key; 34 var key = _data[i].key;
35 if (identical(key, object)) { 35 if (identical(key, object)) {
36 break; 36 break;
37 } 37 }
38 if (key == null) { 38 if (key == null) {
39 doCompact = true; 39 doCompact = true;
40 _data[i] = null; 40 _data[i] = null;
41 } 41 }
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.filter((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 || object is bool || object is num || object is String) { 57 if (object == null || object is bool || object is num || object is String) {
58 throw new ArgumentError(object); 58 throw new ArgumentError(object);
59 } 59 }
60 } 60 }
61 61
62 List _data; 62 List _data;
63 } 63 }
OLDNEW
« no previous file with comments | « runtime/lib/double_patch.dart ('k') | runtime/lib/function_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698