Skip to content

Commit 3ded535

Browse files
Default to nullptr, and assign __hash during construction
1 parent 8e9153e commit 3ded535

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

libcxx/include/__hash_table

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ public:
167167
#endif
168168

169169
template <class _Alloc, class... _Args>
170-
_LIBCPP_HIDE_FROM_ABI explicit __hash_node(__next_pointer __next, size_t __hash, _Alloc& __na, _Args&&... __args)
171-
: _Base(__next), __hash_(__hash) {
170+
_LIBCPP_HIDE_FROM_ABI explicit __hash_node(size_t __hash, _Alloc& __na, _Args&&... __args)
171+
: _Base(nullptr), __hash_(__hash) {
172172
allocator_traits<_Alloc>::construct(__na, std::addressof(__get_value()), std::forward<_Args>(__args)...);
173173
}
174174

@@ -1884,11 +1884,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(_Args&&... __args) {
18841884
// We don't use the allocator's construct() method to construct the node itself since the
18851885
// Cpp17FooInsertable named requirements don't require the allocator's construct() method
18861886
// to work on anything other than the value_type.
1887-
std::__construct_at(std::addressof(*__h), /* next = */ nullptr, /* hash = */ 0, __na, std::forward<_Args>(__args)...);
1887+
std::__construct_at(std::addressof(*__h), /* hash = */ hash_function()(__h->__get_value()), __na, std::forward<_Args>(__args)...);
18881888

18891889
__h.get_deleter().__value_constructed = true;
18901890

1891-
__h->__hash_ = hash_function()(__h->__get_value());
18921891
return __h;
18931892
}
18941893

@@ -1900,7 +1899,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(size_t __hash, _
19001899
__node_allocator& __na = __node_alloc();
19011900
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
19021901
std::__construct_at(
1903-
std::addressof(*__h), /* next = */ nullptr, /* hash = */ __hash, __na, std::forward<_Args>(__args)...);
1902+
std::addressof(*__h), /* hash = */ __hash, __na, std::forward<_Args>(__args)...);
19041903
__h.get_deleter().__value_constructed = true;
19051904
return __h;
19061905
}

0 commit comments

Comments
 (0)