[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.
This commit is contained in:
Louis Dionne 2024-09-04 16:39:09 -04:00 committed by GitHub
parent d21e731c42
commit 23f6c3370b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 2 additions and 16 deletions

View File

@ -9,10 +9,10 @@
#ifndef _LIBCPP___MATH_HYPOT_H
#define _LIBCPP___MATH_HYPOT_H
#include <__algorithm/max.h>
#include <__config>
#include <__math/abs.h>
#include <__math/exponential_functions.h>
#include <__math/min_max.h>
#include <__math/roots.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/is_arithmetic.h>
@ -62,7 +62,7 @@ _LIBCPP_HIDE_FROM_ABI _Real __hypot(_Real __x, _Real __y, _Real __z) {
const _Real __overflow_scale = __math::ldexp(_Real(1), -(__exp + 20));
// Scale arguments depending on their size
const _Real __max_abs = std::max(__math::fabs(__x), std::max(__math::fabs(__y), __math::fabs(__z)));
const _Real __max_abs = __math::fmax(__math::fabs(__x), __math::fmax(__math::fabs(__y), __math::fabs(__z)));
_Real __scale;
if (__max_abs > __overflow_threshold) { // x*x + y*y + z*z might overflow
__scale = __overflow_scale;

View File

@ -131,8 +131,6 @@ chrono type_traits
chrono vector
chrono version
cinttypes cstdint
cmath cstddef
cmath initializer_list
cmath limits
cmath type_traits
cmath version

1 algorithm atomic
131 chrono vector
132 chrono version
133 cinttypes cstdint
cmath cstddef
cmath initializer_list
134 cmath limits
135 cmath type_traits
136 cmath version

View File

@ -131,8 +131,6 @@ chrono type_traits
chrono vector
chrono version
cinttypes cstdint
cmath cstddef
cmath initializer_list
cmath limits
cmath type_traits
cmath version

1 algorithm atomic
131 chrono vector
132 chrono version
133 cinttypes cstdint
cmath cstddef
cmath initializer_list
134 cmath limits
135 cmath type_traits
136 cmath version

View File

@ -132,8 +132,6 @@ chrono type_traits
chrono vector
chrono version
cinttypes cstdint
cmath cstddef
cmath initializer_list
cmath limits
cmath type_traits
cmath version

1 algorithm atomic
132 chrono vector
133 chrono version
134 cinttypes cstdint
cmath cstddef
cmath initializer_list
135 cmath limits
136 cmath type_traits
137 cmath version

View File

@ -132,8 +132,6 @@ chrono type_traits
chrono vector
chrono version
cinttypes cstdint
cmath cstddef
cmath initializer_list
cmath limits
cmath type_traits
cmath version

1 algorithm atomic
132 chrono vector
133 chrono version
134 cinttypes cstdint
cmath cstddef
cmath initializer_list
135 cmath limits
136 cmath type_traits
137 cmath version

View File

@ -137,8 +137,6 @@ chrono type_traits
chrono vector
chrono version
cinttypes cstdint
cmath cstddef
cmath initializer_list
cmath limits
cmath type_traits
cmath version

1 algorithm atomic
137 chrono vector
138 chrono version
139 cinttypes cstdint
cmath cstddef
cmath initializer_list
140 cmath limits
141 cmath type_traits
142 cmath version

View File

@ -84,8 +84,6 @@ chrono string_view
chrono vector
chrono version
cinttypes cstdint
cmath cstddef
cmath initializer_list
cmath limits
cmath version
codecvt cctype

1 algorithm climits
84 chrono vector
85 chrono version
86 cinttypes cstdint
cmath cstddef
cmath initializer_list
87 cmath limits
88 cmath version
89 codecvt cctype

View File

@ -84,8 +84,6 @@ chrono string_view
chrono vector
chrono version
cinttypes cstdint
cmath cstddef
cmath initializer_list
cmath limits
cmath version
codecvt cctype

1 algorithm climits
84 chrono vector
85 chrono version
86 cinttypes cstdint
cmath cstddef
cmath initializer_list
87 cmath limits
88 cmath version
89 codecvt cctype