| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 void TemplateHashMapImpl<AllocationPolicy>::Resize(AllocationPolicy allocator) { | 290 void TemplateHashMapImpl<AllocationPolicy>::Resize(AllocationPolicy allocator) { |
| 291 Entry* map = map_; | 291 Entry* map = map_; |
| 292 uint32_t n = occupancy_; | 292 uint32_t n = occupancy_; |
| 293 | 293 |
| 294 // Allocate larger map. | 294 // Allocate larger map. |
| 295 Initialize(capacity_ * 2, allocator); | 295 Initialize(capacity_ * 2, allocator); |
| 296 | 296 |
| 297 // Rehash all current entries. | 297 // Rehash all current entries. |
| 298 for (Entry* p = map; n > 0; p++) { | 298 for (Entry* p = map; n > 0; p++) { |
| 299 if (p->key != NULL) { | 299 if (p->key != NULL) { |
| 300 Lookup(p->key, p->hash, true)->value = p->value; | 300 Lookup(p->key, p->hash, true, allocator)->value = p->value; |
| 301 n--; | 301 n--; |
| 302 } | 302 } |
| 303 } | 303 } |
| 304 | 304 |
| 305 // Delete old map. | 305 // Delete old map. |
| 306 AllocationPolicy::Delete(map); | 306 AllocationPolicy::Delete(map); |
| 307 } | 307 } |
| 308 | 308 |
| 309 | 309 |
| 310 // A hash map for pointer keys and values with an STL-like interface. | 310 // A hash map for pointer keys and values with an STL-like interface. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 TemplateHashMap( | 342 TemplateHashMap( |
| 343 typename TemplateHashMapImpl<AllocationPolicy>::MatchFun match, | 343 typename TemplateHashMapImpl<AllocationPolicy>::MatchFun match, |
| 344 AllocationPolicy allocator = AllocationPolicy()) | 344 AllocationPolicy allocator = AllocationPolicy()) |
| 345 : TemplateHashMapImpl<AllocationPolicy>( | 345 : TemplateHashMapImpl<AllocationPolicy>( |
| 346 match, | 346 match, |
| 347 TemplateHashMapImpl<AllocationPolicy>::kDefaultHashMapCapacity, | 347 TemplateHashMapImpl<AllocationPolicy>::kDefaultHashMapCapacity, |
| 348 allocator) { } | 348 allocator) { } |
| 349 | 349 |
| 350 Iterator begin() const { return Iterator(this, this->Start()); } | 350 Iterator begin() const { return Iterator(this, this->Start()); } |
| 351 Iterator end() const { return Iterator(this, NULL); } | 351 Iterator end() const { return Iterator(this, NULL); } |
| 352 Iterator find(Key* key, bool insert = false) { | 352 Iterator find(Key* key, bool insert = false, |
| 353 return Iterator(this, this->Lookup(key, key->Hash(), insert)); | 353 AllocationPolicy allocator = AllocationPolicy()) { |
| 354 return Iterator(this, this->Lookup(key, key->Hash(), insert, allocator)); |
| 354 } | 355 } |
| 355 }; | 356 }; |
| 356 | 357 |
| 357 } } // namespace v8::internal | 358 } } // namespace v8::internal |
| 358 | 359 |
| 359 #endif // V8_HASHMAP_H_ | 360 #endif // V8_HASHMAP_H_ |
| OLD | NEW |