Skip to content

Commit 23f6c33

Browse files
authored
[libc++][modules] Remove dependency on __algorithm/max from hypot.h (#107150)
That dependency was added recently when we made improvements to std::hypot, but that resulted in `__math` depending on `__algorithm`, which is a very heavyweight module. This patch uses `__math::fmax` instead.
1 parent d21e731 commit 23f6c33

File tree

8 files changed

+2
-16
lines changed

8 files changed

+2
-16
lines changed

libcxx/include/__math/hypot.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
#ifndef _LIBCPP___MATH_HYPOT_H
1010
#define _LIBCPP___MATH_HYPOT_H
1111

12-
#include <__algorithm/max.h>
1312
#include <__config>
1413
#include <__math/abs.h>
1514
#include <__math/exponential_functions.h>
15+
#include <__math/min_max.h>
1616
#include <__math/roots.h>
1717
#include <__type_traits/enable_if.h>
1818
#include <__type_traits/is_arithmetic.h>
@@ -62,7 +62,7 @@ _LIBCPP_HIDE_FROM_ABI _Real __hypot(_Real __x, _Real __y, _Real __z) {
6262
const _Real __overflow_scale = __math::ldexp(_Real(1), -(__exp + 20));
6363

6464
// Scale arguments depending on their size
65-
const _Real __max_abs = std::max(__math::fabs(__x), std::max(__math::fabs(__y), __math::fabs(__z)));
65+
const _Real __max_abs = __math::fmax(__math::fabs(__x), __math::fmax(__math::fabs(__y), __math::fabs(__z)));
6666
_Real __scale;
6767
if (__max_abs > __overflow_threshold) { // x*x + y*y + z*z might overflow
6868
__scale = __overflow_scale;

libcxx/test/libcxx/transitive_includes/cxx03.csv

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ chrono type_traits
131131
chrono vector
132132
chrono version
133133
cinttypes cstdint
134-
cmath cstddef
135-
cmath initializer_list
136134
cmath limits
137135
cmath type_traits
138136
cmath version

libcxx/test/libcxx/transitive_includes/cxx11.csv

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ chrono type_traits
131131
chrono vector
132132
chrono version
133133
cinttypes cstdint
134-
cmath cstddef
135-
cmath initializer_list
136134
cmath limits
137135
cmath type_traits
138136
cmath version

libcxx/test/libcxx/transitive_includes/cxx14.csv

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ chrono type_traits
132132
chrono vector
133133
chrono version
134134
cinttypes cstdint
135-
cmath cstddef
136-
cmath initializer_list
137135
cmath limits
138136
cmath type_traits
139137
cmath version

libcxx/test/libcxx/transitive_includes/cxx17.csv

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ chrono type_traits
132132
chrono vector
133133
chrono version
134134
cinttypes cstdint
135-
cmath cstddef
136-
cmath initializer_list
137135
cmath limits
138136
cmath type_traits
139137
cmath version

libcxx/test/libcxx/transitive_includes/cxx20.csv

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ chrono type_traits
137137
chrono vector
138138
chrono version
139139
cinttypes cstdint
140-
cmath cstddef
141-
cmath initializer_list
142140
cmath limits
143141
cmath type_traits
144142
cmath version

libcxx/test/libcxx/transitive_includes/cxx23.csv

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ chrono string_view
8484
chrono vector
8585
chrono version
8686
cinttypes cstdint
87-
cmath cstddef
88-
cmath initializer_list
8987
cmath limits
9088
cmath version
9189
codecvt cctype

libcxx/test/libcxx/transitive_includes/cxx26.csv

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ chrono string_view
8484
chrono vector
8585
chrono version
8686
cinttypes cstdint
87-
cmath cstddef
88-
cmath initializer_list
8987
cmath limits
9088
cmath version
9189
codecvt cctype

0 commit comments

Comments
 (0)