Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80390 - trunk/boost/unordered/detail
From: dnljms_at_[hidden]
Date: 2012-09-03 16:06:01


Author: danieljames
Date: 2012-09-03 16:06:00 EDT (Mon, 03 Sep 2012)
New Revision: 80390
URL: http://svn.boost.org/trac/boost/changeset/80390

Log:
Unordered: delete/destroy/clear cleanup.
Text files modified:
   trunk/boost/unordered/detail/table.hpp | 33 ++++++++++++---------------------
   1 files changed, 12 insertions(+), 21 deletions(-)

Modified: trunk/boost/unordered/detail/table.hpp
==============================================================================
--- trunk/boost/unordered/detail/table.hpp (original)
+++ trunk/boost/unordered/detail/table.hpp 2012-09-03 16:06:00 EDT (Mon, 03 Sep 2012)
@@ -516,25 +516,19 @@
             return count;
         }
 
- void delete_extra_node(bucket_pointer) {}
-
- void delete_extra_node(node_pointer n) {
- node_allocator_traits::destroy(node_alloc(), boost::addressof(*n));
- node_allocator_traits::deallocate(node_alloc(), n, 1);
- }
-
         void delete_buckets()
         {
             if(buckets_) {
- previous_pointer prev = get_previous_start();
+ delete_nodes(get_start(), iterator());
 
- while(prev->next_) {
- node_pointer n = static_cast<node_pointer>(prev->next_);
- prev->next_ = n->next_;
- delete_node(iterator(n));
+ if (bucket::extra_node) {
+ node_pointer n = static_cast<node_pointer>(
+ get_bucket(bucket_count_)->next_);
+ node_allocator_traits::destroy(node_alloc(),
+ boost::addressof(*n));
+ node_allocator_traits::deallocate(node_alloc(), n, 1);
                 }
 
- delete_extra_node(prev);
                 destroy_buckets();
                 buckets_ = bucket_pointer();
             }
@@ -546,14 +540,8 @@
         {
             if(!size_) return;
 
- previous_pointer prev = get_previous_start();
-
- while(prev->next_) {
- node_pointer n = static_cast<node_pointer>(prev->next_);
- prev->next_ = n->next_;
- delete_node(iterator(n));
- }
-
+ delete_nodes(get_start(), iterator());
+ get_previous_start()->next_ = link_pointer();
             clear_buckets();
 
             BOOST_ASSERT(!size_);
@@ -581,6 +569,9 @@
                 buckets_, bucket_count_ + 1);
         }
 
+ ////////////////////////////////////////////////////////////////////////
+ // Fix buckets after erase
+
         // This is called after erasing a node or group of nodes to fix up
         // the bucket pointers.
         void fix_buckets(bucket_pointer this_bucket,


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk