OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv
ed. |
3 * Copyright (C) 2008 David Levin <levin@chromium.org> | 3 * Copyright (C) 2008 David Levin <levin@chromium.org> |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 for (unsigned i = 0; i < size; ++i) { | 1002 for (unsigned i = 0; i < size; ++i) { |
1003 // This code is called when the hash table is cleared or | 1003 // This code is called when the hash table is cleared or |
1004 // resized. We have allocated a new backing store and we need | 1004 // resized. We have allocated a new backing store and we need |
1005 // to run the destructors on the old backing store, as it is | 1005 // to run the destructors on the old backing store, as it is |
1006 // being freed. If we are GCing we need to both call the | 1006 // being freed. If we are GCing we need to both call the |
1007 // destructor and mark the bucket as deleted, otherwise the | 1007 // destructor and mark the bucket as deleted, otherwise the |
1008 // destructor gets called again when the GC finds the backing | 1008 // destructor gets called again when the GC finds the backing |
1009 // store. With the default allocator it's enough to call the | 1009 // store. With the default allocator it's enough to call the |
1010 // destructor, since we will free the memory explicitly and | 1010 // destructor, since we will free the memory explicitly and |
1011 // we won't see the memory with the bucket again. | 1011 // we won't see the memory with the bucket again. |
1012 if (!isEmptyOrDeletedBucket(table[i])) { | 1012 if (Allocator::isGarbageCollected) { |
1013 if (Allocator::isGarbageCollected) | 1013 if (!isEmptyOrDeletedBucket(table[i])) |
1014 deleteBucket(table[i]); | 1014 deleteBucket(table[i]); |
1015 else | 1015 } else { |
| 1016 if (!isDeletedBucket(table[i])) |
1016 table[i].~ValueType(); | 1017 table[i].~ValueType(); |
1017 } | 1018 } |
1018 } | 1019 } |
1019 } | 1020 } |
1020 Allocator::freeHashTableBacking(table); | 1021 Allocator::freeHashTableBacking(table); |
1021 } | 1022 } |
1022 | 1023 |
1023 template<typename Key, typename Value, typename Extractor, typename HashFunc
tions, typename Traits, typename KeyTraits, typename Allocator> | 1024 template<typename Key, typename Value, typename Extractor, typename HashFunc
tions, typename Traits, typename KeyTraits, typename Allocator> |
1024 Value* HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Al
locator>::expand(Value* entry) | 1025 Value* HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Al
locator>::expand(Value* entry) |
1025 { | 1026 { |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1448 CollectionIterator end(toBeRemoved.end()); | 1449 CollectionIterator end(toBeRemoved.end()); |
1449 for (CollectionIterator it(toBeRemoved.begin()); it != end; ++it) | 1450 for (CollectionIterator it(toBeRemoved.begin()); it != end; ++it) |
1450 collection.remove(*it); | 1451 collection.remove(*it); |
1451 } | 1452 } |
1452 | 1453 |
1453 } // namespace WTF | 1454 } // namespace WTF |
1454 | 1455 |
1455 #include "wtf/HashIterators.h" | 1456 #include "wtf/HashIterators.h" |
1456 | 1457 |
1457 #endif // WTF_HashTable_h | 1458 #endif // WTF_HashTable_h |
OLD | NEW |