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

Unified Diff: sdk/lib/_internal/compiler/implementation/lib/constant_map.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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/lib/constant_map.dart
diff --git a/sdk/lib/_internal/compiler/implementation/lib/constant_map.dart b/sdk/lib/_internal/compiler/implementation/lib/constant_map.dart
index 53d276e0d1d0514ecf092df983938115e2ab3e0c..fabebbd9409216987699335fed2fef99fe1d1517 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/constant_map.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/constant_map.dart
@@ -13,7 +13,7 @@ class ConstantMap<V> implements Map<String, V> {
final List<String> _keys;
bool containsValue(V needle) {
- return values.some((V value) => value == needle);
+ return values.any((V value) => value == needle);
}
bool containsKey(String key) {
@@ -30,12 +30,12 @@ class ConstantMap<V> implements Map<String, V> {
_keys.forEach((String key) => f(key, this[key]));
}
- Collection<String> get keys => _keys;
+ Iterable<String> get keys {
+ return new _ConstantMapKeyIterable(this);
+ }
- Collection<V> get values {
- List<V> result = <V>[];
- _keys.forEach((String key) => result.add(this[key]));
- return result;
+ Iterable<V> get values {
+ return new MappedIterable<String, V>(_keys, (String key) => this[key]);
}
bool get isEmpty => length == 0;
@@ -66,3 +66,10 @@ class ConstantProtoMap<V> extends ConstantMap<V> {
return super[key];
}
}
+
+class _ConstantMapKeyIterable extends Iterable<String> {
+ ConstantMap _map;
+ _ConstantMapKeyIterable(this._map);
+
+ Iterator<String> get iterator => _map._keys.iterator;
+}

Powered by Google App Engine
This is Rietveld 408576698