| 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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 } | 624 } |
| 625 | 625 |
| 626 template <typename Key, typename Value, typename Extractor, typename HashFunctio
ns, typename Traits, typename KeyTraits, typename Allocator> | 626 template <typename Key, typename Value, typename Extractor, typename HashFunctio
ns, typename Traits, typename KeyTraits, typename Allocator> |
| 627 void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocato
r>::reserveCapacityForSize(unsigned newSize) | 627 void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocato
r>::reserveCapacityForSize(unsigned newSize) |
| 628 { | 628 { |
| 629 unsigned newCapacity = calculateCapacity(newSize); | 629 unsigned newCapacity = calculateCapacity(newSize); |
| 630 if (newCapacity < KeyTraits::minimumTableSize) | 630 if (newCapacity < KeyTraits::minimumTableSize) |
| 631 newCapacity = KeyTraits::minimumTableSize; | 631 newCapacity = KeyTraits::minimumTableSize; |
| 632 | 632 |
| 633 if (newCapacity > capacity()) { | 633 if (newCapacity > capacity()) { |
| 634 CHECK(!static_cast<int>(newCapacity >> 31)); // HashTable capacity shoul
d not overflow 32bit int. | 634 RELEASE_ASSERT(!static_cast<int>(newCapacity >> 31)); // HashTable capac
ity should not overflow 32bit int. |
| 635 rehash(newCapacity, 0); | 635 rehash(newCapacity, 0); |
| 636 } | 636 } |
| 637 } | 637 } |
| 638 | 638 |
| 639 template <typename Key, typename Value, typename Extractor, typename HashFunctio
ns, typename Traits, typename KeyTraits, typename Allocator> | 639 template <typename Key, typename Value, typename Extractor, typename HashFunctio
ns, typename Traits, typename KeyTraits, typename Allocator> |
| 640 template <typename HashTranslator, typename T> | 640 template <typename HashTranslator, typename T> |
| 641 inline Value* HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits,
Allocator>::lookup(const T& key) | 641 inline Value* HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits,
Allocator>::lookup(const T& key) |
| 642 { | 642 { |
| 643 return const_cast<Value*>(const_cast<const HashTable*>(this)->lookup<HashTra
nslator>(key)); | 643 return const_cast<Value*>(const_cast<const HashTable*>(this)->lookup<HashTra
nslator>(key)); |
| 644 } | 644 } |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 template <typename Key, typename Value, typename Extractor, typename HashFunctio
ns, typename Traits, typename KeyTraits, typename Allocator> | 1050 template <typename Key, typename Value, typename Extractor, typename HashFunctio
ns, typename Traits, typename KeyTraits, typename Allocator> |
| 1051 Value* HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Alloca
tor>::expand(Value* entry) | 1051 Value* HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Alloca
tor>::expand(Value* entry) |
| 1052 { | 1052 { |
| 1053 unsigned newSize; | 1053 unsigned newSize; |
| 1054 if (!m_tableSize) { | 1054 if (!m_tableSize) { |
| 1055 newSize = KeyTraits::minimumTableSize; | 1055 newSize = KeyTraits::minimumTableSize; |
| 1056 } else if (mustRehashInPlace()) { | 1056 } else if (mustRehashInPlace()) { |
| 1057 newSize = m_tableSize; | 1057 newSize = m_tableSize; |
| 1058 } else { | 1058 } else { |
| 1059 newSize = m_tableSize * 2; | 1059 newSize = m_tableSize * 2; |
| 1060 CHECK_GT(newSize, m_tableSize); | 1060 RELEASE_ASSERT(newSize > m_tableSize); |
| 1061 } | 1061 } |
| 1062 | 1062 |
| 1063 return rehash(newSize, entry); | 1063 return rehash(newSize, entry); |
| 1064 } | 1064 } |
| 1065 | 1065 |
| 1066 template <typename Key, typename Value, typename Extractor, typename HashFunctio
ns, typename Traits, typename KeyTraits, typename Allocator> | 1066 template <typename Key, typename Value, typename Extractor, typename HashFunctio
ns, typename Traits, typename KeyTraits, typename Allocator> |
| 1067 Value* HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Alloca
tor>::expandBuffer(unsigned newTableSize, Value* entry, bool& success) | 1067 Value* HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Alloca
tor>::expandBuffer(unsigned newTableSize, Value* entry, bool& success) |
| 1068 { | 1068 { |
| 1069 success = false; | 1069 success = false; |
| 1070 ASSERT(m_tableSize < newTableSize); | 1070 ASSERT(m_tableSize < newTableSize); |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 CollectionIterator end(toBeRemoved.end()); | 1524 CollectionIterator end(toBeRemoved.end()); |
| 1525 for (CollectionIterator it(toBeRemoved.begin()); it != end; ++it) | 1525 for (CollectionIterator it(toBeRemoved.begin()); it != end; ++it) |
| 1526 collection.remove(*it); | 1526 collection.remove(*it); |
| 1527 } | 1527 } |
| 1528 | 1528 |
| 1529 } // namespace WTF | 1529 } // namespace WTF |
| 1530 | 1530 |
| 1531 #include "wtf/HashIterators.h" | 1531 #include "wtf/HashIterators.h" |
| 1532 | 1532 |
| 1533 #endif // WTF_HashTable_h | 1533 #endif // WTF_HashTable_h |
| OLD | NEW |