|
Boost-Commit : |
From: daniel_james_at_[hidden]
Date: 2008-04-16 13:31:45
Author: danieljames
Date: 2008-04-16 13:31:45 EDT (Wed, 16 Apr 2008)
New Revision: 44459
URL: http://svn.boost.org/trac/boost/changeset/44459
Log:
Inline construct_node and create_node into copy_group - these used to be used
in the implementation of insert but aren't now because of insert's exception
requirements, so keeping them around was just confusing.
Text files modified:
branches/unordered/trunk/boost/unordered/detail/hash_table_impl.hpp | 71 ++++++++++-----------------------------
1 files changed, 19 insertions(+), 52 deletions(-)
Modified: branches/unordered/trunk/boost/unordered/detail/hash_table_impl.hpp
==============================================================================
--- branches/unordered/trunk/boost/unordered/detail/hash_table_impl.hpp (original)
+++ branches/unordered/trunk/boost/unordered/detail/hash_table_impl.hpp 2008-04-16 13:31:45 EDT (Wed, 16 Apr 2008)
@@ -560,6 +560,8 @@
// no throw
#if BOOST_UNORDERED_EQUIVALENT_KEYS
+ // If n points to the first node in a group, this adds it to the
+ // end of that group.
void link_node(link_ptr n, link_ptr pos)
{
node& node_ref = get_node(n);
@@ -733,69 +735,34 @@
}
#endif
- // throws, strong exception-safety:
- link_ptr construct_node(value_type const& v)
- {
- node_constructor a(allocators_);
- a.construct(v);
- return a.release();
- }
-
- // Create Node
- //
- // Create a node and add it to the buckets in the given position.
+ // copy_group
//
- // strong exception safety.
-
- iterator_base create_node(value_type const& v, bucket_ptr base)
- {
- // throws, strong exception-safety:
- link_ptr n = construct_node(v);
-
- // Rest is no throw
- link_node_in_bucket(n, base);
- return iterator_base(base, n);
- }
+ // Basic exception safety.
+ // If it throws, it only copies some of the nodes in the group.
#if BOOST_UNORDERED_EQUIVALENT_KEYS
- iterator_base create_node(value_type const& v, iterator_base position)
- {
- // throws, strong exception-safety:
- link_ptr n = construct_node(v);
-
- // Rest is no throw
- link_node(n, position.node_);
- return iterator_base(position.bucket_, n);
- }
-
- iterator_base create_node(value_type const& v,
- bucket_ptr base, link_ptr position)
+ void copy_group(link_ptr it, bucket_ptr dst)
{
- // throws, strong exception-safety:
- link_ptr n = construct_node(v);
+ node_constructor a(allocators_);
- // Rest is no throw
- if(BOOST_UNORDERED_BORLAND_BOOL(position))
- link_node(n, position);
- else
- link_node_in_bucket(n, base);
+ link_ptr end = next_group(it);
- return iterator_base(base, n);
- }
-#endif
+ a.construct(get_value(it)); // throws
+ link_ptr n = a.release();
+ link_node_in_bucket(n, dst);
-#if BOOST_UNORDERED_EQUIVALENT_KEYS
- void copy_group(link_ptr it, bucket_ptr dst)
- {
- link_ptr end = next_group(it);
- iterator_base pos = create_node(get_value(it), dst);
- for(it = it->next_; it != end; it = it->next_)
- create_node(get_value(it), pos);
+ for(it = it->next_; it != end; it = it->next_) {
+ a.construct(get_value(it)); // throws
+ link_node(a.release(), n);
+ }
}
#else
void copy_group(link_ptr it, bucket_ptr dst)
{
- create_node(get_value(it), dst);
+ node_constructor a(allocators_);
+
+ a.construct(get_value(it)); // throws
+ link_node_in_bucket(a.release(), dst);
}
#endif
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