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; |
+} |