mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-31 20:04:29 +02:00
Trim down node_tmp code.
This commit is contained in:
@@ -1145,21 +1145,14 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
template <typename NodeAlloc>
|
template <typename NodeAlloc>
|
||||||
struct node_tmp
|
struct node_tmp
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
|
|
||||||
typedef NodeAlloc node_allocator;
|
|
||||||
typedef boost::unordered::detail::allocator_traits<NodeAlloc>
|
typedef boost::unordered::detail::allocator_traits<NodeAlloc>
|
||||||
node_allocator_traits;
|
node_allocator_traits;
|
||||||
typedef typename node_allocator_traits::value_type node;
|
|
||||||
typedef typename node_allocator_traits::pointer node_pointer;
|
typedef typename node_allocator_traits::pointer node_pointer;
|
||||||
typedef typename node::value_type value_type;
|
|
||||||
|
|
||||||
public:
|
NodeAlloc& alloc_;
|
||||||
|
|
||||||
node_allocator& alloc_;
|
|
||||||
node_pointer node_;
|
node_pointer node_;
|
||||||
|
|
||||||
explicit node_tmp(node_pointer n, node_allocator& a):
|
explicit node_tmp(node_pointer n, NodeAlloc& a):
|
||||||
alloc_(a),
|
alloc_(a),
|
||||||
node_(n)
|
node_(n)
|
||||||
{
|
{
|
||||||
@@ -1167,11 +1160,6 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
|
|
||||||
~node_tmp();
|
~node_tmp();
|
||||||
|
|
||||||
value_type const& value() const {
|
|
||||||
BOOST_ASSERT(node_ );
|
|
||||||
return node_->value();
|
|
||||||
}
|
|
||||||
|
|
||||||
// no throw
|
// no throw
|
||||||
node_pointer release()
|
node_pointer release()
|
||||||
{
|
{
|
||||||
|
@@ -428,13 +428,9 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
iterator emplace_impl(node_pointer n)
|
iterator emplace_impl(node_pointer n)
|
||||||
{
|
{
|
||||||
node_tmp a(n, this->node_alloc());
|
node_tmp a(n, this->node_alloc());
|
||||||
|
key_type const& k = this->get_key(a.node_->value());
|
||||||
key_type const& k = this->get_key(a.value());
|
|
||||||
std::size_t key_hash = this->hash(k);
|
std::size_t key_hash = this->hash(k);
|
||||||
iterator position = this->find_node(key_hash, k);
|
iterator position = this->find_node(key_hash, k);
|
||||||
|
|
||||||
// reserve has basic exception safety if the hash function
|
|
||||||
// throws, strong otherwise.
|
|
||||||
this->reserve_for_insert(this->size_ + 1);
|
this->reserve_for_insert(this->size_ + 1);
|
||||||
return this->add_node(a.release(), key_hash, position);
|
return this->add_node(a.release(), key_hash, position);
|
||||||
}
|
}
|
||||||
@@ -442,7 +438,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
void emplace_impl_no_rehash(node_pointer n)
|
void emplace_impl_no_rehash(node_pointer n)
|
||||||
{
|
{
|
||||||
node_tmp a(n, this->node_alloc());
|
node_tmp a(n, this->node_alloc());
|
||||||
key_type const& k = this->get_key(a.value());
|
key_type const& k = this->get_key(a.node_->value());
|
||||||
std::size_t key_hash = this->hash(k);
|
std::size_t key_hash = this->hash(k);
|
||||||
iterator position = this->find_node(key_hash, k);
|
iterator position = this->find_node(key_hash, k);
|
||||||
this->add_node(a.release(), key_hash, position);
|
this->add_node(a.release(), key_hash, position);
|
||||||
|
@@ -421,14 +421,10 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
boost::unordered::detail::func::construct_value_generic(
|
boost::unordered::detail::func::construct_value_generic(
|
||||||
this->node_alloc(), BOOST_UNORDERED_EMPLACE_FORWARD),
|
this->node_alloc(), BOOST_UNORDERED_EMPLACE_FORWARD),
|
||||||
this->node_alloc());
|
this->node_alloc());
|
||||||
key_type const& k = this->get_key(b.value());
|
key_type const& k = this->get_key(b.node_->value());
|
||||||
std::size_t key_hash = this->hash(k);
|
std::size_t key_hash = this->hash(k);
|
||||||
iterator pos = this->find_node(key_hash, k);
|
iterator pos = this->find_node(key_hash, k);
|
||||||
|
|
||||||
if (pos.node_) { return emplace_return(pos, false); }
|
if (pos.node_) { return emplace_return(pos, false); }
|
||||||
|
|
||||||
// reserve has basic exception safety if the hash function
|
|
||||||
// throws, strong otherwise.
|
|
||||||
this->reserve_for_insert(this->size_ + 1);
|
this->reserve_for_insert(this->size_ + 1);
|
||||||
return emplace_return(this->add_node(b.release(), key_hash), true);
|
return emplace_return(this->add_node(b.release(), key_hash), true);
|
||||||
}
|
}
|
||||||
@@ -478,8 +474,6 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
if(this->size_ + 1 > this->max_load_)
|
if(this->size_ + 1 > this->max_load_)
|
||||||
this->reserve_for_insert(this->size_ +
|
this->reserve_for_insert(this->size_ +
|
||||||
boost::unordered::detail::insert_size(i, j));
|
boost::unordered::detail::insert_size(i, j));
|
||||||
|
|
||||||
// Nothing after this point can throw.
|
|
||||||
this->add_node(b.release(), key_hash);
|
this->add_node(b.release(), key_hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -495,7 +489,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
a.alloc_, a.node_->value_ptr(), *i);
|
a.alloc_, a.node_->value_ptr(), *i);
|
||||||
node_tmp b(a.release(), a.alloc_);
|
node_tmp b(a.release(), a.alloc_);
|
||||||
|
|
||||||
key_type const& k = this->get_key(b.value());
|
key_type const& k = this->get_key(b.node_->value());
|
||||||
std::size_t key_hash = this->hash(k);
|
std::size_t key_hash = this->hash(k);
|
||||||
iterator pos = this->find_node(key_hash, k);
|
iterator pos = this->find_node(key_hash, k);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user