| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #ifndef RUNTIME_VM_HASH_MAP_H_ | 5 #ifndef RUNTIME_VM_HASH_MAP_H_ |
| 6 #define RUNTIME_VM_HASH_MAP_H_ | 6 #define RUNTIME_VM_HASH_MAP_H_ |
| 7 | 7 |
| 8 #include "vm/growable_array.h" // For Malloc, EmptyBase | 8 #include "vm/growable_array.h" // For Malloc, EmptyBase |
| 9 #include "vm/zone.h" | 9 #include "vm/zone.h" |
| 10 | 10 |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 lists_[next] = HashMapListElement(); | 325 lists_[next] = HashMapListElement(); |
| 326 lists_[next].next = free_list_head_; | 326 lists_[next].next = free_list_head_; |
| 327 free_list_head_ = next; | 327 free_list_head_ = next; |
| 328 } | 328 } |
| 329 count_--; | 329 count_--; |
| 330 return true; | 330 return true; |
| 331 } | 331 } |
| 332 | 332 |
| 333 intptr_t current = array_[pos].next; | 333 intptr_t current = array_[pos].next; |
| 334 | 334 |
| 335 // If there's only the single element in the bucket and it does not match the |
| 336 // key to be removed, just return. |
| 337 if (current == kNil) { |
| 338 return false; |
| 339 } |
| 340 |
| 335 // Check the case where the second element in the bucket is the one to be | 341 // Check the case where the second element in the bucket is the one to be |
| 336 // removed. | 342 // removed. |
| 337 if (KeyValueTrait::KeyOf(lists_[current].kv) == key) { | 343 if (KeyValueTrait::KeyOf(lists_[current].kv) == key) { |
| 338 array_[pos].next = lists_[current].next; | 344 array_[pos].next = lists_[current].next; |
| 339 lists_[current] = HashMapListElement(); | 345 lists_[current] = HashMapListElement(); |
| 340 lists_[current].next = free_list_head_; | 346 lists_[current].next = free_list_head_; |
| 341 free_list_head_ = current; | 347 free_list_head_ = current; |
| 342 count_--; | 348 count_--; |
| 343 return true; | 349 return true; |
| 344 } | 350 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 | 437 |
| 432 static Key KeyOf(Pair kv) { return kv.key; } | 438 static Key KeyOf(Pair kv) { return kv.key; } |
| 433 static Value ValueOf(Pair kv) { return kv.value; } | 439 static Value ValueOf(Pair kv) { return kv.value; } |
| 434 static intptr_t Hashcode(Key key) { return reinterpret_cast<intptr_t>(key); } | 440 static intptr_t Hashcode(Key key) { return reinterpret_cast<intptr_t>(key); } |
| 435 static bool IsKeyEqual(Pair kv, Key key) { return kv.key == key; } | 441 static bool IsKeyEqual(Pair kv, Key key) { return kv.key == key; } |
| 436 }; | 442 }; |
| 437 | 443 |
| 438 } // namespace dart | 444 } // namespace dart |
| 439 | 445 |
| 440 #endif // RUNTIME_VM_HASH_MAP_H_ | 446 #endif // RUNTIME_VM_HASH_MAP_H_ |
| OLD | NEW |