Skip to content

Commit 0dd8c0d

Browse files
authored
[libc++] Remove a few includes from <__hash_table> (#99738)
1 parent d07fdf9 commit 0dd8c0d

File tree

5 files changed

+12
-14
lines changed

5 files changed

+12
-14
lines changed

libcxx/include/__hash_table

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <__functional/hash.h>
1919
#include <__functional/invoke.h>
2020
#include <__iterator/iterator_traits.h>
21+
#include <__math/rounding_functions.h>
2122
#include <__memory/addressof.h>
2223
#include <__memory/allocator_traits.h>
2324
#include <__memory/compressed_pair.h>
@@ -40,9 +41,8 @@
4041
#include <__utility/move.h>
4142
#include <__utility/pair.h>
4243
#include <__utility/swap.h>
43-
#include <cmath>
4444
#include <cstring>
45-
#include <initializer_list>
45+
#include <limits>
4646
#include <new> // __launder
4747

4848
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -875,10 +875,10 @@ public:
875875
_LIBCPP_HIDE_FROM_ABI void __rehash_unique(size_type __n) { __rehash<true>(__n); }
876876
_LIBCPP_HIDE_FROM_ABI void __rehash_multi(size_type __n) { __rehash<false>(__n); }
877877
_LIBCPP_HIDE_FROM_ABI void __reserve_unique(size_type __n) {
878-
__rehash_unique(static_cast<size_type>(std::ceil(__n / max_load_factor())));
878+
__rehash_unique(static_cast<size_type>(__math::ceil(__n / max_load_factor())));
879879
}
880880
_LIBCPP_HIDE_FROM_ABI void __reserve_multi(size_type __n) {
881-
__rehash_multi(static_cast<size_type>(std::ceil(__n / max_load_factor())));
881+
__rehash_multi(static_cast<size_type>(__math::ceil(__n / max_load_factor())));
882882
}
883883

884884
_LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __bucket_list_.get_deleter().size(); }
@@ -1348,7 +1348,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(size_t __
13481348
}
13491349
if (size() + 1 > __bc * max_load_factor() || __bc == 0) {
13501350
__rehash_unique(std::max<size_type>(
1351-
2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor()))));
1351+
2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor()))));
13521352
}
13531353
return nullptr;
13541354
}
@@ -1408,7 +1408,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare(size_t __c
14081408
size_type __bc = bucket_count();
14091409
if (size() + 1 > __bc * max_load_factor() || __bc == 0) {
14101410
__rehash_multi(std::max<size_type>(
1411-
2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor()))));
1411+
2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor()))));
14121412
__bc = bucket_count();
14131413
}
14141414
size_t __chash = std::__constrain_hash(__cp_hash, __bc);
@@ -1483,7 +1483,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(const_iterator __p
14831483
size_type __bc = bucket_count();
14841484
if (size() + 1 > __bc * max_load_factor() || __bc == 0) {
14851485
__rehash_multi(std::max<size_type>(
1486-
2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor()))));
1486+
2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor()))));
14871487
__bc = bucket_count();
14881488
}
14891489
size_t __chash = std::__constrain_hash(__cp->__hash_, __bc);
@@ -1523,7 +1523,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&
15231523
__node_holder __h = __construct_node_hash(__hash, std::forward<_Args>(__args)...);
15241524
if (size() + 1 > __bc * max_load_factor() || __bc == 0) {
15251525
__rehash_unique(std::max<size_type>(
1526-
2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor()))));
1526+
2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor()))));
15271527
__bc = bucket_count();
15281528
__chash = std::__constrain_hash(__hash, __bc);
15291529
}
@@ -1692,8 +1692,8 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __n) _LIBCPP_D
16921692
else if (__n < __bc) {
16931693
__n = std::max<size_type>(
16941694
__n,
1695-
std::__is_hash_power2(__bc) ? std::__next_hash_pow2(size_t(std::ceil(float(size()) / max_load_factor())))
1696-
: std::__next_prime(size_t(std::ceil(float(size()) / max_load_factor()))));
1695+
std::__is_hash_power2(__bc) ? std::__next_hash_pow2(size_t(__math::ceil(float(size()) / max_load_factor())))
1696+
: std::__next_prime(size_t(__math::ceil(float(size()) / max_load_factor()))));
16971697
if (__n < __bc)
16981698
__do_rehash<_UniqueKeys>(__n);
16991699
}

libcxx/include/unordered_map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2532,6 +2532,7 @@ _LIBCPP_POP_MACROS
25322532
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
25332533
# include <algorithm>
25342534
# include <bit>
2535+
# include <cmath>
25352536
# include <concepts>
25362537
# include <cstdlib>
25372538
# include <iterator>

libcxx/include/unordered_set

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,7 @@ _LIBCPP_END_NAMESPACE_STD
18001800
_LIBCPP_POP_MACROS
18011801

18021802
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1803+
# include <cmath>
18031804
# include <concepts>
18041805
# include <cstdlib>
18051806
# include <functional>

libcxx/test/libcxx/transitive_includes/cxx23.csv

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,6 @@ typeindex typeinfo
655655
typeindex version
656656
typeinfo cstddef
657657
typeinfo cstdint
658-
unordered_map cmath
659658
unordered_map compare
660659
unordered_map cstddef
661660
unordered_map cstdint
@@ -667,7 +666,6 @@ unordered_map optional
667666
unordered_map stdexcept
668667
unordered_map tuple
669668
unordered_map version
670-
unordered_set cmath
671669
unordered_set compare
672670
unordered_set cstddef
673671
unordered_set cstdint

libcxx/test/libcxx/transitive_includes/cxx26.csv

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,6 @@ typeindex typeinfo
655655
typeindex version
656656
typeinfo cstddef
657657
typeinfo cstdint
658-
unordered_map cmath
659658
unordered_map compare
660659
unordered_map cstddef
661660
unordered_map cstdint
@@ -667,7 +666,6 @@ unordered_map optional
667666
unordered_map stdexcept
668667
unordered_map tuple
669668
unordered_map version
670-
unordered_set cmath
671669
unordered_set compare
672670
unordered_set cstddef
673671
unordered_set cstdint

0 commit comments

Comments
 (0)