Re: PR 71181 Avoid rehash after reserve

2016-06-17 Thread Jonathan Wakely
On 16/06/16 21:29 +0200, François Dumont wrote: Here is a new version compiling all your feedbacks. PR libstdc++/71181 * include/tr1/hashtable_policy.h (_Prime_rehash_policy::_M_next_bkt): Make past-the-end iterator dereferenceable to avoid check on lower_bound result. (_Prime_reh

Re: PR 71181 Avoid rehash after reserve

2016-06-16 Thread François Dumont
Here is a new version compiling all your feedbacks. PR libstdc++/71181 * include/tr1/hashtable_policy.h (_Prime_rehash_policy::_M_next_bkt): Make past-the-end iterator dereferenceable to avoid check on lower_bound result. (_Prime_rehash_policy::_M_bkt_for_elements): Call latte

Re: PR 71181 Avoid rehash after reserve

2016-06-15 Thread Jonathan Wakely
On 14/06/16 22:34 +0200, François Dumont wrote: On 14/06/2016 13:22, Jonathan Wakely wrote: On 13/06/16 21:49 +0200, François Dumont wrote: Hi I eventually would like to propose the attached patch. In tr1 I made sure we use a special past-the-end iterator that makes usage of lower_bound

Re: PR 71181 Avoid rehash after reserve

2016-06-14 Thread François Dumont
On 14/06/2016 13:22, Jonathan Wakely wrote: On 13/06/16 21:49 +0200, François Dumont wrote: Hi I eventually would like to propose the attached patch. In tr1 I made sure we use a special past-the-end iterator that makes usage of lower_bound result without check safe. I'm confused ... i

Re: PR 71181 Avoid rehash after reserve

2016-06-14 Thread Jonathan Wakely
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/71181.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/71181.cc new file mode 100644 index 000..e0c0259 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/71181.cc @

Re: PR 71181 Avoid rehash after reserve

2016-06-14 Thread Jonathan Wakely
On 13/06/16 21:49 +0200, François Dumont wrote: Hi I eventually would like to propose the attached patch. In tr1 I made sure we use a special past-the-end iterator that makes usage of lower_bound result without check safe. I'm confused ... isn't that already done? _S_n_primes is defin

Re: PR 71181 Avoid rehash after reserve

2016-06-13 Thread François Dumont
Hi I eventually would like to propose the attached patch. In tr1 I made sure we use a special past-the-end iterator that makes usage of lower_bound result without check safe. PR libstdc++/71181 * include/tr1/hashtable_policy.h (_Prime_rehash_policy::_M_next_bkt): Make past

Re: PR 71181 Avoid rehash after reserve

2016-05-25 Thread François Dumont
On 25/05/2016 16:01, Jonathan Wakely wrote: On 22/05/16 17:16 +0200, François Dumont wrote: Hi To fix 71181 problem I propose to change how we deal with reserve called with pivot values that is to say prime numbers. Now _M_next_bkt always return a value higher than the input value. This w

Re: PR 71181 Avoid rehash after reserve

2016-05-25 Thread Jonathan Wakely
On 22/05/16 17:16 +0200, François Dumont wrote: Hi To fix 71181 problem I propose to change how we deal with reserve called with pivot values that is to say prime numbers. Now _M_next_bkt always return a value higher than the input value. This way when reverse(97) is called we end up with

PR 71181 Avoid rehash after reserve

2016-05-22 Thread François Dumont
Hi To fix 71181 problem I propose to change how we deal with reserve called with pivot values that is to say prime numbers. Now _M_next_bkt always return a value higher than the input value. This way when reverse(97) is called we end up with 199 buckets and so enough space to store 97 val