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

Unified Diff: runtime/lib/expando_patch.dart

Issue 10909209: Eliminate the const constructor from the Expando class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address review comments Created 8 years, 3 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
« no previous file with comments | « lib/core/expando.dart ('k') | tests/corelib/expando_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « lib/core/expando.dart ('k') | tests/corelib/expando_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698