| OLD | NEW |
| 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 file for dart:collection classes. | 5 // Patch file for dart:collection classes. |
| 6 import 'dart:_foreign_helper' show JS; | 6 import 'dart:_foreign_helper' show JS; |
| 7 import 'dart:_js_helper' show | 7 import 'dart:_js_helper' show |
| 8 fillLiteralMap, InternalMap, NoInline, NoThrows, patch, JsLinkedHashMap, | 8 fillLiteralMap, InternalMap, NoInline, NoThrows, patch, JsLinkedHashMap, |
| 9 LinkedHashMapCell, LinkedHashMapKeyIterable, LinkedHashMapKeyIterator; | 9 LinkedHashMapCell, LinkedHashMapKeyIterable, LinkedHashMapKeyIterator; |
| 10 | 10 |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 // issues with problematic keys like '__proto__'. Another option | 537 // issues with problematic keys like '__proto__'. Another option |
| 538 // would be to throw an exception if the hash code isn't a number. | 538 // would be to throw an exception if the hash code isn't a number. |
| 539 return JS('int', '# & 0x3ffffff', identityHashCode(key)); | 539 return JS('int', '# & 0x3ffffff', identityHashCode(key)); |
| 540 } | 540 } |
| 541 | 541 |
| 542 int internalFindBucketIndex(var bucket, var key) { | 542 int internalFindBucketIndex(var bucket, var key) { |
| 543 if (bucket == null) return -1; | 543 if (bucket == null) return -1; |
| 544 int length = JS('int', '#.length', bucket); | 544 int length = JS('int', '#.length', bucket); |
| 545 for (int i = 0; i < length; i++) { | 545 for (int i = 0; i < length; i++) { |
| 546 LinkedHashMapCell cell = JS('var', '#[#]', bucket, i); | 546 LinkedHashMapCell cell = JS('var', '#[#]', bucket, i); |
| 547 if (identical(cell.key, key)) return i; | 547 if (identical(cell.hashMapCellKey, key)) return i; |
| 548 } | 548 } |
| 549 return -1; | 549 return -1; |
| 550 } | 550 } |
| 551 } | 551 } |
| 552 | 552 |
| 553 class _LinkedCustomHashMap<K, V> extends JsLinkedHashMap<K, V> { | 553 class _LinkedCustomHashMap<K, V> extends JsLinkedHashMap<K, V> { |
| 554 final _Equality<K> _equals; | 554 final _Equality<K> _equals; |
| 555 final _Hasher<K> _hashCode; | 555 final _Hasher<K> _hashCode; |
| 556 final _Predicate _validKey; | 556 final _Predicate _validKey; |
| 557 _LinkedCustomHashMap(this._equals, this._hashCode, | 557 _LinkedCustomHashMap(this._equals, this._hashCode, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 582 // issues with problematic keys like '__proto__'. Another option | 582 // issues with problematic keys like '__proto__'. Another option |
| 583 // would be to throw an exception if the hash code isn't a number. | 583 // would be to throw an exception if the hash code isn't a number. |
| 584 return JS('int', '# & 0x3ffffff', _hashCode(key)); | 584 return JS('int', '# & 0x3ffffff', _hashCode(key)); |
| 585 } | 585 } |
| 586 | 586 |
| 587 int internalFindBucketIndex(var bucket, var key) { | 587 int internalFindBucketIndex(var bucket, var key) { |
| 588 if (bucket == null) return -1; | 588 if (bucket == null) return -1; |
| 589 int length = JS('int', '#.length', bucket); | 589 int length = JS('int', '#.length', bucket); |
| 590 for (int i = 0; i < length; i++) { | 590 for (int i = 0; i < length; i++) { |
| 591 LinkedHashMapCell cell = JS('var', '#[#]', bucket, i); | 591 LinkedHashMapCell cell = JS('var', '#[#]', bucket, i); |
| 592 if (_equals(cell.key, key)) return i; | 592 if (_equals(cell.hashMapCellKey, key)) return i; |
| 593 } | 593 } |
| 594 return -1; | 594 return -1; |
| 595 } | 595 } |
| 596 } | 596 } |
| 597 | 597 |
| 598 @patch | 598 @patch |
| 599 class HashSet<E> { | 599 class HashSet<E> { |
| 600 @patch | 600 @patch |
| 601 factory HashSet({ bool equals(E e1, E e2), | 601 factory HashSet({ bool equals(E e1, E e2), |
| 602 int hashCode(E e), | 602 int hashCode(E e), |
| (...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 } else if (_cell == null) { | 1458 } else if (_cell == null) { |
| 1459 _current = null; | 1459 _current = null; |
| 1460 return false; | 1460 return false; |
| 1461 } else { | 1461 } else { |
| 1462 _current = _cell._element; | 1462 _current = _cell._element; |
| 1463 _cell = _cell._next; | 1463 _cell = _cell._next; |
| 1464 return true; | 1464 return true; |
| 1465 } | 1465 } |
| 1466 } | 1466 } |
| 1467 } | 1467 } |
| OLD | NEW |