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

Side by Side Diff: runtime/lib/collection_patch.dart

Issue 380333002: Add VM class for Map/LinkedHashMap. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/lib/collection_sources.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 patch class HashMap<K, V> { 5 patch class HashMap<K, V> {
6 /* patch */ factory HashMap({ bool equals(K key1, K key2), 6 /* patch */ factory HashMap({ bool equals(K key1, K key2),
7 int hashCode(K key), 7 int hashCode(K key),
8 bool isValidKey(potentialKey) }) { 8 bool isValidKey(potentialKey) }) {
9 if (isValidKey == null) { 9 if (isValidKey == null) {
10 if (hashCode == null) { 10 if (hashCode == null) {
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 /// only the head entry itself). 899 /// only the head entry itself).
900 var _nextEntry; 900 var _nextEntry;
901 var _previousEntry; 901 var _previousEntry;
902 902
903 /* patch */ factory LinkedHashMap({ bool equals(K key1, K key2), 903 /* patch */ factory LinkedHashMap({ bool equals(K key1, K key2),
904 int hashCode(K key), 904 int hashCode(K key),
905 bool isValidKey(potentialKey) }) { 905 bool isValidKey(potentialKey) }) {
906 if (isValidKey == null) { 906 if (isValidKey == null) {
907 if (hashCode == null) { 907 if (hashCode == null) {
908 if (equals == null) { 908 if (equals == null) {
909 return new _LinkedHashMap<K, V>(); 909 if (_useInternalCached) {
910 return new _InternalLinkedHashMap<K, V>();
911 } else {
912 return new _LinkedHashMap<K, V>();
913 }
910 } 914 }
911 hashCode = _defaultHashCode; 915 hashCode = _defaultHashCode;
912 } else { 916 } else {
913 if (identical(identityHashCode, hashCode) && 917 if (identical(identityHashCode, hashCode) &&
914 identical(identical, equals)) { 918 identical(identical, equals)) {
915 return new _LinkedIdentityHashMap<K, V>(); 919 return new _LinkedIdentityHashMap<K, V>();
916 } 920 }
917 if (equals == null) { 921 if (equals == null) {
918 equals = _defaultEquals; 922 equals = _defaultEquals;
919 } 923 }
920 } 924 }
921 } else { 925 } else {
922 if (hashCode == null) { 926 if (hashCode == null) {
923 hashCode = _defaultHashCode; 927 hashCode = _defaultHashCode;
924 } 928 }
925 if (equals == null) { 929 if (equals == null) {
926 equals = _defaultEquals; 930 equals = _defaultEquals;
927 } 931 }
928 } 932 }
929 return new _LinkedCustomHashMap<K, V>(equals, hashCode, isValidKey); 933 return new _LinkedCustomHashMap<K, V>(equals, hashCode, isValidKey);
930 } 934 }
931 935
932 /* patch */ factory LinkedHashMap.identity() = _LinkedIdentityHashMap<K, V>; 936 /* patch */ factory LinkedHashMap.identity() = _LinkedIdentityHashMap<K, V>;
937
938 static final bool _useInternalCached = _useInternal;
939 static bool get _useInternal native "LinkedHashMap_useInternal";
933 } 940 }
934 941
935 // Methods that are exactly the same in all three linked hash map variants. 942 // Methods that are exactly the same in all three linked hash map variants.
936 abstract class _LinkedHashMapMixin<K, V> implements LinkedHashMap<K, V> { 943 abstract class _LinkedHashMapMixin<K, V> implements LinkedHashMap<K, V> {
937 var _nextEntry; 944 var _nextEntry;
938 var _previousEntry; 945 var _previousEntry;
939 946
940 947
941 bool containsValue(Object value) { 948 bool containsValue(Object value) {
942 int modificationCount = _modificationCount; 949 int modificationCount = _modificationCount;
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 return false; 1253 return false;
1247 } 1254 }
1248 _LinkedHashSetEntry entry = _next; 1255 _LinkedHashSetEntry entry = _next;
1249 _current = entry.key; 1256 _current = entry.key;
1250 _next = entry._nextEntry; 1257 _next = entry._nextEntry;
1251 return true; 1258 return true;
1252 } 1259 }
1253 1260
1254 E get current => _current; 1261 E get current => _current;
1255 } 1262 }
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/collection_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698