From 291e91daa73361a1f4a426a879f89c1ea6cf0e9f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Dumont?= Date: Sun, 5 Jul 2015 21:16:07 +0000 Subject: [PATCH] hashtable.h (_Hashtable<>::__rehash_policy): Do not rehash container. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2015-07-05 François Dumont * include/bits/hashtable.h (_Hashtable<>::__rehash_policy): Do not rehash container. * testsuite/23_containers/unordered_set/max_load_factor/robustness.cc: Adapt. From-SVN: r225436 --- libstdc++-v3/ChangeLog | 7 ++++ libstdc++-v3/include/bits/hashtable.h | 19 ++--------- .../max_load_factor/robustness.cc | 34 +++++++++++-------- 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index b9db195575c..86e9d4cfbfe 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2015-07-05 François Dumont + + * include/bits/hashtable.h (_Hashtable<>::__rehash_policy): Do not + rehash container. + * testsuite/23_containers/unordered_set/max_load_factor/robustness.cc: + Adapt. + 2015-07-03 Jonathan Wakely * doc/xml/manual/status_cxx2017.xml: Update status table. diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h index 48810044079..0495f4bdd2f 100644 --- a/libstdc++-v3/include/bits/hashtable.h +++ b/libstdc++-v3/include/bits/hashtable.h @@ -594,7 +594,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return _M_rehash_policy; } void - __rehash_policy(const _RehashPolicy&); + __rehash_policy(const _RehashPolicy& __pol) + { _M_rehash_policy = __pol; } // Lookup. iterator @@ -1280,22 +1281,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION = &__x._M_before_begin; } - template - void - _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, _Traits>:: - __rehash_policy(const _RehashPolicy& __pol) - { - auto __do_rehash = - __pol._M_need_rehash(_M_bucket_count, _M_element_count, 0); - if (__do_rehash.first) - _M_rehash(__do_rehash.second, _M_rehash_policy._M_state()); - _M_rehash_policy = __pol; - } - template us.max_load_factor() ); + while (true) { __gnu_cxx::limit_condition::set_limit(counter++); bool do_break = false; try { - us.max_load_factor(.5f); + size_t nbkts = us.bucket_count(); + // Check that unordered_set will still be correctly resized when + // needed. + VERIFY( us.insert(val++).second ); + + VERIFY( us.bucket_count() != nbkts ); + VERIFY( us.load_factor() <= us.max_load_factor() ); do_break = true; } catch (const __gnu_cxx::forced_error&) { - VERIFY( us.max_load_factor() == cur_max_load_factor ); + // max load factor doesn't change. + VERIFY( us.max_load_factor() == .5f ); ++thrown_exceptions; } - // Lets check that unordered_set will still be correctly resized - // when needed - __gnu_cxx::limit_condition::set_limit(nl_size_t::max()); - for (;;) - { - VERIFY( us.load_factor() <= us.max_load_factor() ); - size_t nbkts = us.bucket_count(); - VERIFY( us.insert(val++).second ); - if (us.bucket_count() != nbkts) - break; - } + if (do_break) break; } + VERIFY( thrown_exceptions > 0 ); } -- 2.30.2