Skip to content

[libc++] Remove a few includes from <__hash_table> #99738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions libcxx/include/__hash_table
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <__functional/hash.h>
#include <__functional/invoke.h>
#include <__iterator/iterator_traits.h>
#include <__math/rounding_functions.h>
#include <__memory/addressof.h>
#include <__memory/allocator_traits.h>
#include <__memory/compressed_pair.h>
Expand All @@ -40,9 +41,8 @@
#include <__utility/move.h>
#include <__utility/pair.h>
#include <__utility/swap.h>
#include <cmath>
#include <cstring>
#include <initializer_list>
#include <limits>
#include <new> // __launder

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Expand Down Expand Up @@ -875,10 +875,10 @@ public:
_LIBCPP_HIDE_FROM_ABI void __rehash_unique(size_type __n) { __rehash<true>(__n); }
_LIBCPP_HIDE_FROM_ABI void __rehash_multi(size_type __n) { __rehash<false>(__n); }
_LIBCPP_HIDE_FROM_ABI void __reserve_unique(size_type __n) {
__rehash_unique(static_cast<size_type>(std::ceil(__n / max_load_factor())));
__rehash_unique(static_cast<size_type>(__math::ceil(__n / max_load_factor())));
}
_LIBCPP_HIDE_FROM_ABI void __reserve_multi(size_type __n) {
__rehash_multi(static_cast<size_type>(std::ceil(__n / max_load_factor())));
__rehash_multi(static_cast<size_type>(__math::ceil(__n / max_load_factor())));
}

_LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __bucket_list_.get_deleter().size(); }
Expand Down Expand Up @@ -1348,7 +1348,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(size_t __
}
if (size() + 1 > __bc * max_load_factor() || __bc == 0) {
__rehash_unique(std::max<size_type>(
2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor()))));
2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor()))));
}
return nullptr;
}
Expand Down Expand Up @@ -1408,7 +1408,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare(size_t __c
size_type __bc = bucket_count();
if (size() + 1 > __bc * max_load_factor() || __bc == 0) {
__rehash_multi(std::max<size_type>(
2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor()))));
2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor()))));
__bc = bucket_count();
}
size_t __chash = std::__constrain_hash(__cp_hash, __bc);
Expand Down Expand Up @@ -1483,7 +1483,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(const_iterator __p
size_type __bc = bucket_count();
if (size() + 1 > __bc * max_load_factor() || __bc == 0) {
__rehash_multi(std::max<size_type>(
2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor()))));
2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor()))));
__bc = bucket_count();
}
size_t __chash = std::__constrain_hash(__cp->__hash_, __bc);
Expand Down Expand Up @@ -1523,7 +1523,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&
__node_holder __h = __construct_node_hash(__hash, std::forward<_Args>(__args)...);
if (size() + 1 > __bc * max_load_factor() || __bc == 0) {
__rehash_unique(std::max<size_type>(
2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor()))));
2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor()))));
__bc = bucket_count();
__chash = std::__constrain_hash(__hash, __bc);
}
Expand Down Expand Up @@ -1692,8 +1692,8 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __n) _LIBCPP_D
else if (__n < __bc) {
__n = std::max<size_type>(
__n,
std::__is_hash_power2(__bc) ? std::__next_hash_pow2(size_t(std::ceil(float(size()) / max_load_factor())))
: std::__next_prime(size_t(std::ceil(float(size()) / max_load_factor()))));
std::__is_hash_power2(__bc) ? std::__next_hash_pow2(size_t(__math::ceil(float(size()) / max_load_factor())))
: std::__next_prime(size_t(__math::ceil(float(size()) / max_load_factor()))));
if (__n < __bc)
__do_rehash<_UniqueKeys>(__n);
}
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/unordered_map
Original file line number Diff line number Diff line change
Expand Up @@ -2532,6 +2532,7 @@ _LIBCPP_POP_MACROS
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <algorithm>
# include <bit>
# include <cmath>
# include <concepts>
# include <cstdlib>
# include <iterator>
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/unordered_set
Original file line number Diff line number Diff line change
Expand Up @@ -1800,6 +1800,7 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <cmath>
# include <concepts>
# include <cstdlib>
# include <functional>
Expand Down
2 changes: 0 additions & 2 deletions libcxx/test/libcxx/transitive_includes/cxx23.csv
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,6 @@ typeindex typeinfo
typeindex version
typeinfo cstddef
typeinfo cstdint
unordered_map cmath
unordered_map compare
unordered_map cstddef
unordered_map cstdint
Expand All @@ -661,7 +660,6 @@ unordered_map optional
unordered_map stdexcept
unordered_map tuple
unordered_map version
unordered_set cmath
unordered_set compare
unordered_set cstddef
unordered_set cstdint
Expand Down
2 changes: 0 additions & 2 deletions libcxx/test/libcxx/transitive_includes/cxx26.csv
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,6 @@ typeindex typeinfo
typeindex version
typeinfo cstddef
typeinfo cstdint
unordered_map cmath
unordered_map compare
unordered_map cstddef
unordered_map cstdint
Expand All @@ -661,7 +660,6 @@ unordered_map optional
unordered_map stdexcept
unordered_map tuple
unordered_map version
unordered_set cmath
unordered_set compare
unordered_set cstddef
unordered_set cstdint
Expand Down
Loading