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 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 remove(find(key)); | 988 remove(find(key)); |
989 } | 989 } |
990 | 990 |
991 template <typename Key, typename Value, typename Extractor, typename HashFunctio
ns, typename Traits, typename KeyTraits, typename Allocator> | 991 template <typename Key, typename Value, typename Extractor, typename HashFunctio
ns, typename Traits, typename KeyTraits, typename Allocator> |
992 Value* HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Alloca
tor>::allocateTable(unsigned size) | 992 Value* HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Alloca
tor>::allocateTable(unsigned size) |
993 { | 993 { |
994 size_t allocSize = size * sizeof(ValueType); | 994 size_t allocSize = size * sizeof(ValueType); |
995 ValueType* result; | 995 ValueType* result; |
996 // Assert that we will not use memset on things with a vtable entry. The | 996 // Assert that we will not use memset on things with a vtable entry. The |
997 // compiler will also check this on some platforms. We would like to check | 997 // compiler will also check this on some platforms. We would like to check |
998 // this on the whole value (key-value pair), but IsPolymorphic will return | 998 // this on the whole value (key-value pair), but std::is_polymorphic will re
turn |
999 // false for a pair of two types, even if one of the components is | 999 // false for a pair of two types, even if one of the components is |
1000 // polymorphic. | 1000 // polymorphic. |
1001 static_assert(!Traits::emptyValueIsZero || !IsPolymorphic<KeyType>::value, "
empty value cannot be zero for things with a vtable"); | 1001 static_assert(!Traits::emptyValueIsZero || !std::is_polymorphic<KeyType>::va
lue, "empty value cannot be zero for things with a vtable"); |
1002 | 1002 |
1003 #if ENABLE(OILPAN) | 1003 #if ENABLE(OILPAN) |
1004 static_assert(Allocator::isGarbageCollected | 1004 static_assert(Allocator::isGarbageCollected |
1005 || ((!AllowsOnlyPlacementNew<KeyType>::value || !NeedsTracing<KeyType>::
value) | 1005 || ((!AllowsOnlyPlacementNew<KeyType>::value || !NeedsTracing<KeyType>::
value) |
1006 && (!AllowsOnlyPlacementNew<ValueType>::value || !NeedsTracing<ValueType
>::value)) | 1006 && (!AllowsOnlyPlacementNew<ValueType>::value || !NeedsTracing<ValueType
>::value)) |
1007 , "Cannot put DISALLOW_NEW_EXCEPT_PLACEMENT_NEW objects that have trace
methods into an off-heap HashTable"); | 1007 , "Cannot put DISALLOW_NEW_EXCEPT_PLACEMENT_NEW objects that have trace
methods into an off-heap HashTable"); |
1008 #endif | 1008 #endif |
1009 if (Traits::emptyValueIsZero) { | 1009 if (Traits::emptyValueIsZero) { |
1010 result = Allocator::template allocateZeroedHashTableBacking<ValueType, H
ashTable>(allocSize); | 1010 result = Allocator::template allocateZeroedHashTableBacking<ValueType, H
ashTable>(allocSize); |
1011 } else { | 1011 } else { |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1489 CollectionIterator end(toBeRemoved.end()); | 1489 CollectionIterator end(toBeRemoved.end()); |
1490 for (CollectionIterator it(toBeRemoved.begin()); it != end; ++it) | 1490 for (CollectionIterator it(toBeRemoved.begin()); it != end; ++it) |
1491 collection.remove(*it); | 1491 collection.remove(*it); |
1492 } | 1492 } |
1493 | 1493 |
1494 } // namespace WTF | 1494 } // namespace WTF |
1495 | 1495 |
1496 #include "wtf/HashIterators.h" | 1496 #include "wtf/HashIterators.h" |
1497 | 1497 |
1498 #endif // WTF_HashTable_h | 1498 #endif // WTF_HashTable_h |
OLD | NEW |