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

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

Issue 22561003: Convert null-marker in HashMap.forEach. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | tests/language/hash_map_null_key_foreach_test.dart » ('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 final _HashMapTable<K, V> _hashTable = new _HashMapTable<K, V>(); 6 final _HashMapTable<K, V> _hashTable = new _HashMapTable<K, V>();
7 7
8 /* patch */ HashMap() { 8 /* patch */ HashMap() {
9 _hashTable._container = this; 9 _hashTable._container = this;
10 } 10 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 _hashTable._clear(); 87 _hashTable._clear();
88 } 88 }
89 89
90 /* patch */ void forEach(void action(K key, V value)) { 90 /* patch */ void forEach(void action(K key, V value)) {
91 int modificationCount = _hashTable._modificationCount; 91 int modificationCount = _hashTable._modificationCount;
92 List table = _hashTable._table; 92 List table = _hashTable._table;
93 int entrySize = _hashTable._entrySize; 93 int entrySize = _hashTable._entrySize;
94 for (int offset = 0; offset < table.length; offset += entrySize) { 94 for (int offset = 0; offset < table.length; offset += entrySize) {
95 Object entry = table[offset]; 95 Object entry = table[offset];
96 if (!_hashTable._isFree(entry)) { 96 if (!_hashTable._isFree(entry)) {
97 K key = entry; 97 K key = identical(entry, _NULL) ? null : entry;
98 V value = _hashTable._value(offset); 98 V value = _hashTable._value(offset);
99 action(key, value); 99 action(key, value);
100 _hashTable._checkModification(modificationCount); 100 _hashTable._checkModification(modificationCount);
101 } 101 }
102 } 102 }
103 } 103 }
104 104
105 /* patch */ Iterable<K> get keys => new _HashTableKeyIterable<K>(_hashTable); 105 /* patch */ Iterable<K> get keys => new _HashTableKeyIterable<K>(_hashTable);
106 /* patch */ Iterable<V> get values => 106 /* patch */ Iterable<V> get values =>
107 new _HashTableValueIterable<V>(_hashTable, _HashMapTable._VALUE_INDEX); 107 new _HashTableValueIterable<V>(_hashTable, _HashMapTable._VALUE_INDEX);
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 1001
1002 _LinkedHashMapTable() : super(_INITIAL_CAPACITY); 1002 _LinkedHashMapTable() : super(_INITIAL_CAPACITY);
1003 1003
1004 V _value(int offset) => _table[offset + _VALUE_INDEX]; 1004 V _value(int offset) => _table[offset + _VALUE_INDEX];
1005 void _setValue(int offset, V value) { _table[offset + _VALUE_INDEX] = value; } 1005 void _setValue(int offset, V value) { _table[offset + _VALUE_INDEX] = value; }
1006 1006
1007 _copyEntry(List oldTable, int fromOffset, int toOffset) { 1007 _copyEntry(List oldTable, int fromOffset, int toOffset) {
1008 _table[toOffset + _VALUE_INDEX] = oldTable[fromOffset + _VALUE_INDEX]; 1008 _table[toOffset + _VALUE_INDEX] = oldTable[fromOffset + _VALUE_INDEX];
1009 } 1009 }
1010 } 1010 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/hash_map_null_key_foreach_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698