| 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 fillLiteralMap, NoInline; | 7 import 'dart:_js_helper' show fillLiteralMap, NoInline; |
| 8 | 8 |
| 9 patch class HashMap<K, V> { | 9 patch class HashMap<K, V> { |
| 10 patch factory HashMap({ bool equals(K key1, K key2), | 10 patch factory HashMap({ bool equals(K key1, K key2), |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 } else if (_isNumericKey(key)) { | 605 } else if (_isNumericKey(key)) { |
| 606 var nums = _nums; | 606 var nums = _nums; |
| 607 if (nums == null) return null; | 607 if (nums == null) return null; |
| 608 LinkedHashMapCell cell = _getTableEntry(nums, key); | 608 LinkedHashMapCell cell = _getTableEntry(nums, key); |
| 609 return (cell == null) ? null : cell._value; | 609 return (cell == null) ? null : cell._value; |
| 610 } else { | 610 } else { |
| 611 return _get(key); | 611 return _get(key); |
| 612 } | 612 } |
| 613 } | 613 } |
| 614 | 614 |
| 615 V _get(K key) { | 615 V _get(Object key) { |
| 616 var rest = _rest; | 616 var rest = _rest; |
| 617 if (rest == null) return null; | 617 if (rest == null) return null; |
| 618 var bucket = _getBucket(rest, key); | 618 var bucket = _getBucket(rest, key); |
| 619 int index = _findBucketIndex(bucket, key); | 619 int index = _findBucketIndex(bucket, key); |
| 620 if (index < 0) return null; | 620 if (index < 0) return null; |
| 621 LinkedHashMapCell cell = JS('var', '#[#]', bucket, index); | 621 LinkedHashMapCell cell = JS('var', '#[#]', bucket, index); |
| 622 return cell._value; | 622 return cell._value; |
| 623 } | 623 } |
| 624 | 624 |
| 625 void operator[]=(K key, V value) { | 625 void operator[]=(K key, V value) { |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 bool remove(Object object) { | 1103 bool remove(Object object) { |
| 1104 if (_isStringElement(object)) { | 1104 if (_isStringElement(object)) { |
| 1105 return _removeHashTableEntry(_strings, object); | 1105 return _removeHashTableEntry(_strings, object); |
| 1106 } else if (_isNumericElement(object)) { | 1106 } else if (_isNumericElement(object)) { |
| 1107 return _removeHashTableEntry(_nums, object); | 1107 return _removeHashTableEntry(_nums, object); |
| 1108 } else { | 1108 } else { |
| 1109 return _remove(object); | 1109 return _remove(object); |
| 1110 } | 1110 } |
| 1111 } | 1111 } |
| 1112 | 1112 |
| 1113 bool _remove(object) { | 1113 bool _remove(Object object) { |
| 1114 var rest = _rest; | 1114 var rest = _rest; |
| 1115 if (rest == null) return false; | 1115 if (rest == null) return false; |
| 1116 var bucket = _getBucket(rest, object); | 1116 var bucket = _getBucket(rest, object); |
| 1117 int index = _findBucketIndex(bucket, object); | 1117 int index = _findBucketIndex(bucket, object); |
| 1118 if (index < 0) return false; | 1118 if (index < 0) return false; |
| 1119 // TODO(kasperl): Consider getting rid of the bucket list when | 1119 // TODO(kasperl): Consider getting rid of the bucket list when |
| 1120 // the length reaches zero. | 1120 // the length reaches zero. |
| 1121 _length--; | 1121 _length--; |
| 1122 _elements = null; | 1122 _elements = null; |
| 1123 // TODO(kasperl): It would probably be faster to move the | 1123 // TODO(kasperl): It would probably be faster to move the |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1873 } else if (_cell == null) { | 1873 } else if (_cell == null) { |
| 1874 _current = null; | 1874 _current = null; |
| 1875 return false; | 1875 return false; |
| 1876 } else { | 1876 } else { |
| 1877 _current = _cell._element; | 1877 _current = _cell._element; |
| 1878 _cell = _cell._next; | 1878 _cell = _cell._next; |
| 1879 return true; | 1879 return true; |
| 1880 } | 1880 } |
| 1881 } | 1881 } |
| 1882 } | 1882 } |
| OLD | NEW |