OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * Copyright (C) 2008 David Levin <levin@chromium.org> | 4 * Copyright (C) 2008 David Levin <levin@chromium.org> |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 1809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1820 #if DCHECK_IS_ON() | 1820 #if DCHECK_IS_ON() |
1821 , | 1821 , |
1822 m_accessForbidden(false), | 1822 m_accessForbidden(false), |
1823 m_modifications(0) | 1823 m_modifications(0) |
1824 #endif | 1824 #endif |
1825 #if DUMP_HASHTABLE_STATS_PER_TABLE | 1825 #if DUMP_HASHTABLE_STATS_PER_TABLE |
1826 , | 1826 , |
1827 m_stats(HashTableStatsPtr<Allocator>::copy(other.m_stats)) | 1827 m_stats(HashTableStatsPtr<Allocator>::copy(other.m_stats)) |
1828 #endif | 1828 #endif |
1829 { | 1829 { |
| 1830 if (other.size()) |
| 1831 reserveCapacityForSize(other.size()); |
1830 // Copy the hash table the dumb way, by adding each element to the new | 1832 // Copy the hash table the dumb way, by adding each element to the new |
1831 // table. It might be more efficient to copy the table slots, but it's not | 1833 // table. It might be more efficient to copy the table slots, but it's not |
1832 // clear that efficiency is needed. | 1834 // clear that efficiency is needed. |
1833 const_iterator end = other.end(); | 1835 for (const auto& element : other) |
1834 for (const_iterator it = other.begin(); it != end; ++it) | 1836 add(element); |
1835 add(*it); | |
1836 } | 1837 } |
1837 | 1838 |
1838 template <typename Key, | 1839 template <typename Key, |
1839 typename Value, | 1840 typename Value, |
1840 typename Extractor, | 1841 typename Extractor, |
1841 typename HashFunctions, | 1842 typename HashFunctions, |
1842 typename Traits, | 1843 typename Traits, |
1843 typename KeyTraits, | 1844 typename KeyTraits, |
1844 typename Allocator> | 1845 typename Allocator> |
1845 HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>:: | 1846 HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>:: |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2270 CollectionIterator end(toBeRemoved.end()); | 2271 CollectionIterator end(toBeRemoved.end()); |
2271 for (CollectionIterator it(toBeRemoved.begin()); it != end; ++it) | 2272 for (CollectionIterator it(toBeRemoved.begin()); it != end; ++it) |
2272 collection.erase(*it); | 2273 collection.erase(*it); |
2273 } | 2274 } |
2274 | 2275 |
2275 } // namespace WTF | 2276 } // namespace WTF |
2276 | 2277 |
2277 #include "wtf/HashIterators.h" | 2278 #include "wtf/HashIterators.h" |
2278 | 2279 |
2279 #endif // WTF_HashTable_h | 2280 #endif // WTF_HashTable_h |
OLD | NEW |