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

Unified Diff: sdk/lib/_internal/compiler/js_lib/collection_patch.dart

Issue 1032783003: dart2js: use Es6 maps when available. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Mark empty-hashmap creation as having no side-effect. Created 5 years, 8 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/js_lib/collection_patch.dart
diff --git a/sdk/lib/_internal/compiler/js_lib/collection_patch.dart b/sdk/lib/_internal/compiler/js_lib/collection_patch.dart
index 9242d392644fff7ec59795c0debf71fa905b9f4b..8fc49b210ef35ef8be7e8af4a573146f0e452187 100644
--- a/sdk/lib/_internal/compiler/js_lib/collection_patch.dart
+++ b/sdk/lib/_internal/compiler/js_lib/collection_patch.dart
@@ -5,8 +5,9 @@
// Patch file for dart:collection classes.
import 'dart:_foreign_helper' show JS;
import 'dart:_js_helper' show
- fillLiteralMap, InternalMap, NoInline, NoThrows, patch, JsLinkedHashMap,
- LinkedHashMapCell, LinkedHashMapKeyIterable, LinkedHashMapKeyIterator;
+ fillLiteralMap, InternalMap, NoInline, NoSideEffects, NoThrows, patch,
+ JsLinkedHashMap, LinkedHashMapCell, LinkedHashMapKeyIterable,
+ LinkedHashMapKeyIterator;
@patch
class HashMap<K, V> {
@@ -386,6 +387,7 @@ class _CustomHashMap<K, V> extends _HashMap<K, V> {
final _Equality<K> _equals;
final _Hasher<K> _hashCode;
final _Predicate _validKey;
+
_CustomHashMap(this._equals, this._hashCode, bool validKey(potentialKey))
: _validKey = (validKey != null) ? validKey : ((v) => v is K);
@@ -492,7 +494,7 @@ class LinkedHashMap<K, V> {
if (isValidKey == null) {
if (hashCode == null) {
if (equals == null) {
- return new JsLinkedHashMap<K, V>();
+ return new JsLinkedHashMap<K, V>.es6();
}
hashCode = _defaultHashCode;
} else {
@@ -521,16 +523,17 @@ class LinkedHashMap<K, V> {
// Private factory constructor called by generated code for map literals.
@NoInline()
factory LinkedHashMap._literal(List keyValuePairs) {
- return fillLiteralMap(keyValuePairs, new JsLinkedHashMap<K, V>());
+ return fillLiteralMap(keyValuePairs, new JsLinkedHashMap<K, V>.es6());
}
// Private factory constructor called by generated code for map literals.
- @NoThrows() @NoInline()
+ @NoThrows() @NoInline() @NoSideEffects()
factory LinkedHashMap._empty() {
- return new JsLinkedHashMap<K, V>();
+ return new JsLinkedHashMap<K, V>.es6();
}
}
+// TODO(floitsch): use ES6 Maps when available.
class _LinkedIdentityHashMap<K, V> extends JsLinkedHashMap<K, V> {
int internalComputeHashCode(var key) {
// We force the hash codes to be unsigned 30-bit integers to avoid
@@ -550,10 +553,12 @@ class _LinkedIdentityHashMap<K, V> extends JsLinkedHashMap<K, V> {
}
}
+// TODO(floitsch): use ES6 maps when available.
class _LinkedCustomHashMap<K, V> extends JsLinkedHashMap<K, V> {
final _Equality<K> _equals;
final _Hasher<K> _hashCode;
final _Predicate _validKey;
+
_LinkedCustomHashMap(this._equals, this._hashCode,
bool validKey(potentialKey))
: _validKey = (validKey != null) ? validKey : ((v) => v is K);
« no previous file with comments | « sdk/lib/_internal/compiler/js_lib/annotations.dart ('k') | sdk/lib/_internal/compiler/js_lib/linked_hash_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698