Chromium Code Reviews| Index: Source/wtf/HashTable.h |
| diff --git a/Source/wtf/HashTable.h b/Source/wtf/HashTable.h |
| index 1289ad48d6c4be60639102583a9b3161c093c0db..84ed89cceef318cc87bf332a52d9e8540a1a7874 100644 |
| --- a/Source/wtf/HashTable.h |
| +++ b/Source/wtf/HashTable.h |
| @@ -280,10 +280,12 @@ namespace WTF { |
| HashTable(); |
| ~HashTable() |
| { |
| - if (LIKELY(!m_table)) |
| - return; |
| - deallocateTable(m_table, m_tableSize); |
| - m_table = 0; |
| + if (!Allocator::isGarbageCollected) { |
|
tkent
2014/03/05 01:12:40
nit: We prefer early return.
{
if (Allocator:
|
| + if (LIKELY(!m_table)) |
| + return; |
| + deallocateTable(m_table, m_tableSize); |
| + m_table = 0; |
| + } |
| } |
| HashTable(const HashTable&); |
| @@ -887,13 +889,15 @@ namespace WTF { |
| template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits, typename Allocator> |
| void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::deallocateTable(ValueType* table, unsigned size) |
| { |
| - if (Traits::needsDestruction) { |
| - for (unsigned i = 0; i < size; ++i) { |
| - if (!isDeletedBucket(table[i])) |
| - table[i].~ValueType(); |
| + if (!Allocator::isGarbageCollected) { |
| + if (Traits::needsDestruction) { |
| + for (unsigned i = 0; i < size; ++i) { |
| + if (!isDeletedBucket(table[i])) |
| + table[i].~ValueType(); |
| + } |
| } |
| + Allocator::backingFree(table); |
| } |
| - Allocator::backingFree(table); |
| } |
| template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits, typename Allocator> |