diff options
author | fdumont <fdumont@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-29 07:45:58 +0000 |
---|---|---|
committer | fdumont <fdumont@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-29 07:45:58 +0000 |
commit | 9f119d65900833fa560f033b0039b79beb2646c8 (patch) | |
tree | 9a9ec4da9401072fba5355ee158be75f6a46ec0b /libstdc++-v3/include/bits/hashtable.h | |
parent | 5f6c88358173a14035c34918c8585f155f180e34 (diff) | |
download | gcc-9f119d65900833fa560f033b0039b79beb2646c8.tar.gz |
2011-11-29 François Dumont <fdumont@gcc.gnu.org>
* include/bits/hashtable.h (_Hashtable<>::_M_rehash): Remove code
useless now that the hashtable implementation put the hash code in
cache if the hash functor throws.
* testsuite/23_containers/unordered_set/erase/1.cc: Enhance test by
checking also distance between begin and end iterators to validate
underlying data model.
* testsuite/23_containers/unordered_multiset/erase/1.cc: Likewise.
* testsuire/23_containers/unordered_map/erase/1.cc: Likewise.
* testsuite/23_containers/unordered_multimap/erase/1.cc: Likewise.
* testsuite/23_containers/unordered_multiset/erase/2.cc: New.
* testsuite/23_containers/unordered_multimap/erase/2.cc: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181799 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/bits/hashtable.h')
-rw-r--r-- | libstdc++-v3/include/bits/hashtable.h | 44 |
1 files changed, 5 insertions, 39 deletions
diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h index dfa91f7cc8c..712b1df91c2 100644 --- a/libstdc++-v3/include/bits/hashtable.h +++ b/libstdc++-v3/include/bits/hashtable.h @@ -233,11 +233,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void _M_deallocate_node(_Node* __n); - // Deallocate all nodes contained in the bucket array, buckets' nodes - // are not linked to each other - void - _M_deallocate_nodes(_Bucket*, size_type); - // Deallocate the linked list of nodes pointed to by __n void _M_deallocate_nodes(_Node* __n); @@ -591,19 +586,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - _M_deallocate_nodes(_Bucket* __buckets, size_type __n) - { - for (size_type __i = 0; __i != __n; ++__i) - _M_deallocate_nodes(__buckets[__i]); - } - - template<typename _Key, typename _Value, - typename _Allocator, typename _ExtractKey, typename _Equal, - typename _H1, typename _H2, typename _Hash, typename _RehashPolicy, - bool __chc, bool __cit, bool __uk> - void - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: _M_deallocate_nodes(_Node* __n) { while (__n) @@ -1542,11 +1524,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: _M_rehash(size_type __n, const _RehashPolicyState& __state) { - _Bucket* __new_buckets = nullptr; - _Node* __p = _M_buckets[_M_begin_bucket_index]; __try { - __new_buckets = _M_allocate_buckets(__n); + _Bucket* __new_buckets = _M_allocate_buckets(__n); + _Node* __p = _M_buckets[_M_begin_bucket_index]; // First loop to store each node in its new bucket while (__p) { @@ -1591,24 +1572,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } __catch(...) { - if (__new_buckets) - { - // A failure here means that a hash function threw an exception. - // We can't restore the previous state without calling the hash - // function again, so the only sensible recovery is to delete - // everything. - _M_deallocate_nodes(__new_buckets, __n); - _M_deallocate_buckets(__new_buckets, __n); - _M_deallocate_nodes(__p); - __builtin_memset(_M_buckets, 0, sizeof(_Bucket) * _M_bucket_count); - _M_element_count = 0; - _M_begin_bucket_index = _M_bucket_count; - _M_rehash_policy._M_reset(_RehashPolicyState()); - } - else - // A failure here means that buckets allocation failed. We only - // have to restore hash policy previous state. - _M_rehash_policy._M_reset(__state); + // A failure here means that buckets allocation failed. We only + // have to restore hash policy previous state. + _M_rehash_policy._M_reset(__state); __throw_exception_again; } } |