Index: runtime/lib/expando_patch.dart |
diff --git a/runtime/lib/expando_patch.dart b/runtime/lib/expando_patch.dart |
index e3763370a224531962b5d295c2d7f39ff3faf095..62898c790b51ab0c659e6dabe4cce67845ff1770 100644 |
--- a/runtime/lib/expando_patch.dart |
+++ b/runtime/lib/expando_patch.dart |
@@ -3,55 +3,53 @@ |
// BSD-style license that can be found in the LICENSE file. |
patch class Expando<T> { |
+ /* patch */ Expando([this.name]) : _data = new List(); |
+ |
/* patch */ T operator[](Object object) { |
_checkType(object); |
- var weakProperty = _find(this); |
- var list = weakProperty.value; |
var doCompact = false; |
var result = null; |
- for (int i = 0; i < list.length; ++i) { |
- var key = list[i].key; |
+ for (int i = 0; i < _data.length; ++i) { |
+ var key = _data[i].key; |
if (key === object) { |
- result = list[i].value; |
+ result = _data[i].value; |
break; |
} |
if (key === null) { |
doCompact = true; |
- list[i] = null; |
+ _data[i] = null; |
} |
} |
if (doCompact) { |
- weakProperty.value = list.filter((e) => (e !== null)); |
+ _data = _data.filter((e) => (e !== null)); |
} |
return result; |
} |
/* patch */ void operator[]=(Object object, T value) { |
_checkType(object); |
- var weakProperty = _find(this); |
- var list = weakProperty.value; |
var doCompact = false; |
int i = 0; |
- for (; i < list.length; ++i) { |
- var key = list[i].key; |
+ for (; i < _data.length; ++i) { |
+ var key = _data[i].key; |
if (key === object) { |
break; |
} |
if (key === null) { |
doCompact = true; |
- list[i] = null; |
+ _data[i] = null; |
} |
} |
- if (i !== list.length && value === null) { |
+ if (i !== _data.length && value === null) { |
doCompact = true; |
- list[i] = null; |
- } else if (i !== list.length) { |
- list[i].value = value; |
+ _data[i] = null; |
+ } else if (i !== _data.length) { |
+ _data[i].value = value; |
} else { |
- list.add(new _WeakProperty(object, value)); |
+ _data.add(new _WeakProperty(object, value)); |
} |
if (doCompact) { |
- weakProperty.value = list.filter((e) => (e !== null)); |
+ _data = _data.filter((e) => (e !== null)); |
} |
} |
@@ -64,29 +62,5 @@ patch class Expando<T> { |
} |
} |
- static _find(expando) { |
- if (_data === null) _data = new List(); |
- var doCompact = false; |
- int i = 0; |
- for (; i < _data.length; ++i) { |
- var key = _data[i].key; |
- if (key == expando) { |
- break; |
- } |
- if (key === null) { |
- doCompact = true; |
- _data[i] = null; |
- } |
- } |
- if (i == _data.length) { |
- _data.add(new _WeakProperty(expando, new List())); |
- } |
- var result = _data[i]; |
- if (doCompact) { |
- _data = _data.filter((e) => (e !== null)); |
- } |
- return result; |
- } |
- |
- static List _data; |
+ List _data; |
} |