| 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 library dart2js.util.maplet; | 5 library dart2js.util.maplet; |
| 6 | 6 |
| 7 import 'dart:collection' show MapBase, IterableBase; | 7 import 'dart:collection' show MapBase, IterableBase; |
| 8 | 8 |
| 9 class Maplet<K, V> extends MapBase<K, V> { | 9 class Maplet<K, V> extends MapBase<K, V> { |
| 10 static const _MARKER = const _MapletMarker(); | 10 static const _MARKER = const _MapletMarker(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } else if (_key == key) { | 94 } else if (_key == key) { |
| 95 _value = value; | 95 _value = value; |
| 96 } else { | 96 } else { |
| 97 List list = new List(CAPACITY * 2); | 97 List list = new List(CAPACITY * 2); |
| 98 list[0] = _key; | 98 list[0] = _key; |
| 99 list[1] = key; | 99 list[1] = key; |
| 100 list[CAPACITY] = _value; | 100 list[CAPACITY] = _value; |
| 101 list[CAPACITY + 1] = value; | 101 list[CAPACITY + 1] = value; |
| 102 _key = list; | 102 _key = list; |
| 103 _value = null; | 103 _value = null; |
| 104 _extra = 2; // Two elements. | 104 _extra = 2; // Two elements. |
| 105 } | 105 } |
| 106 } else if (_MARKER == _extra) { | 106 } else if (_MARKER == _extra) { |
| 107 _key[key] = value; | 107 _key[key] = value; |
| 108 } else { | 108 } else { |
| 109 int remaining = _extra; | 109 int remaining = _extra; |
| 110 int index = 0; | 110 int index = 0; |
| 111 int copyTo, copyFrom; | 111 int copyTo, copyFrom; |
| 112 while (remaining > 0 && index < CAPACITY) { | 112 while (remaining > 0 && index < CAPACITY) { |
| 113 var candidate = _key[index]; | 113 var candidate = _key[index]; |
| 114 if (_MARKER == candidate) { | 114 if (_MARKER == candidate) { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 var candidate = _list[_index++]; | 270 var candidate = _list[_index++]; |
| 271 if (Maplet._MARKER != candidate) { | 271 if (Maplet._MARKER != candidate) { |
| 272 _current = candidate; | 272 _current = candidate; |
| 273 _remaining--; | 273 _remaining--; |
| 274 return true; | 274 return true; |
| 275 } | 275 } |
| 276 } | 276 } |
| 277 _current = null; | 277 _current = null; |
| 278 return false; | 278 return false; |
| 279 } | 279 } |
| 280 } | 280 } |
| OLD | NEW |