OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // Efficient JavaScript based implementation of a linked hash map used as a | 5 // Efficient JavaScript based implementation of a linked hash map used as a |
6 // backing map for constant maps and the [LinkedHashMap] patch | 6 // backing map for constant maps and the [LinkedHashMap] patch |
7 | 7 |
8 part of dart._js_helper; | 8 part of dart._js_helper; |
9 | 9 |
10 // DDC-specific, just use Object-backed maps | 10 // DDC-specific, just use Object-backed maps |
11 //const _USE_ES6_MAPS = const bool.fromEnvironment("dart2js.use.es6.maps"); | 11 //const _USE_ES6_MAPS = const bool.fromEnvironment("dart2js.use.es6.maps"); |
12 | 12 |
13 class JsLinkedHashMap<K, V> implements LinkedHashMap<K, V>, InternalMap { | 13 class JsLinkedHashMap<K, V> implements LinkedHashMap<K, V>, InternalMap<K, V> { |
14 int _length = 0; | 14 int _length = 0; |
15 | 15 |
16 // The hash map contents are divided into three parts: one part for | 16 // The hash map contents are divided into three parts: one part for |
17 // string keys, one for numeric keys, and one for the rest. String | 17 // string keys, one for numeric keys, and one for the rest. String |
18 // and numeric keys map directly to their linked cells, but the rest | 18 // and numeric keys map directly to their linked cells, but the rest |
19 // of the entries are stored in bucket lists of the form: | 19 // of the entries are stored in bucket lists of the form: |
20 // | 20 // |
21 // [cell-0, cell-1, ...] | 21 // [cell-0, cell-1, ...] |
22 // | 22 // |
23 // where all keys in the same bucket share the same hash code. | 23 // where all keys in the same bucket share the same hash code. |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 } else if (_cell == null) { | 429 } else if (_cell == null) { |
430 _current = null; | 430 _current = null; |
431 return false; | 431 return false; |
432 } else { | 432 } else { |
433 _current = _cell.hashMapCellKey; | 433 _current = _cell.hashMapCellKey; |
434 _cell = _cell._next; | 434 _cell = _cell._next; |
435 return true; | 435 return true; |
436 } | 436 } |
437 } | 437 } |
438 } | 438 } |
OLD | NEW |