hash policy patch

François Dumont francois.cppdevs@free.fr
Tue Jul 26 20:15:00 GMT 2011


Hi

     Here is an other patch proposal to refactor some code in hash 
policy implementation and to fix a potentially exception safety issue in 
hashtable. If an exception is raised when hashtable is rehash we need to 
restore previous resize value if we still want to guaranty max load factor.

     In _M_insert_bucket I have introduced an other try/catch block 
around_M_rehash because resize value must be restore only if rehash fail 
and not if an exception is raised later. However I don't think any 
exception can be thrown later in this method, maybe the deallocation of 
the node could be move in the catch clause I have introduce and the 
other try/catch block could be removed.

2011-07-26  François Dumont <francois.cppdevs@free.fr>

         * include/bits/hashtable_policy.h (_Prime_rehash_policy): Reuse
         _M_next_bkt as much as possible.
         * include/bits/hashtable.h: Rollback hash policy next resize 
value if
         rehash generate an exception.

François
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hash_policy.patch
Type: text/x-patch
Size: 3427 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20110726/fc7b1463/attachment.bin>


More information about the Libstdc++ mailing list