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