Index: boost/unordered/detail/unique.hpp =================================================================== --- boost/unordered/detail/unique.hpp (revision 66126) +++ boost/unordered/detail/unique.hpp (working copy) @@ -100,6 +100,8 @@ void insert_range_impl(key_type const&, InputIt i, InputIt j); template void insert_range_impl(no_key, InputIt i, InputIt j); + + void locate_node(key_type const&, std::size_t&, bucket_ptr&, node_ptr&); }; template @@ -421,6 +423,18 @@ // Insert range methods template + inline void hash_unique_table::locate_node( + key_type const& k, + std::size_t& hash_value, + bucket_ptr& bucket, + node_ptr& pos) + { + hash_value = this->hash_function()(k); + bucket = this->bucket_ptr_from_hash(hash_value); + pos = this->find_iterator(bucket, k); + } + + template template inline void hash_unique_table::insert_range_impl( key_type const&, InputIt i, InputIt j) @@ -439,11 +453,12 @@ // Note: can't use get_key as '*i' might not be value_type - it // could be a pair with first_types as key_type without const or a // different second_type. - key_type const& k = extractor::extract(*i); - std::size_t hash_value = this->hash_function()(k); - bucket_ptr bucket = this->bucket_ptr_from_hash(hash_value); - node_ptr pos = this->find_iterator(bucket, k); + std::size_t hash_value; + bucket_ptr bucket; + node_ptr pos; + locate_node(extractor::extract(*i), hash_value, bucket, pos); + if (!BOOST_UNORDERED_BORLAND_BOOL(pos)) { // Doesn't already exist, add to bucket. // Side effects only in this block.