diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2020-10-06 00:05:11 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2020-10-06 00:05:11 +0100 |
commit | 9af65c2b9047168f14e623d55f87beda33ba1503 (patch) | |
tree | bed8b420d0dd9cbb74392afae4b379de69c79d4e /libstdc++-v3/include/bits/regex.h | |
parent | 66a032079309069fec085fff2a014ac217ce5781 (diff) | |
download | gcc-9af65c2b9047168f14e623d55f87beda33ba1503.tar.gz |
libstdc++: Reduce uses of std::numeric_limits
This avoids unnecessary instantiations of std::numeric_limits or
inclusion of <limits> when a more lightweight alternative would work.
Some uses can be replaced with __gnu_cxx::__int_traits and some can just
use size_t(-1) directly where SIZE_MAX is needed.
libstdc++-v3/ChangeLog:
* include/bits/regex.h: Use __int_traits<int> instead of
std::numeric_limits<int>.
* include/bits/uniform_int_dist.h: Use __int_traits<T>::__max
instead of std::numeric_limits<T>::max().
* include/bits/hashtable_policy.h: Use size_t(-1) instead of
std::numeric_limits<size_t>::max().
* include/std/regex: Include <ext/numeric_traits.h>.
* include/std/string_view: Use typedef for __int_traits<int>.
* src/c++11/hashtable_c++0x.cc: Use size_t(-1) instead of
std::numeric_limits<size_t>::max().
* testsuite/std/ranges/iota/96042.cc: Include <limits>.
* testsuite/std/ranges/iota/difference_type.cc: Likewise.
* testsuite/std/ranges/subrange/96042.cc: Likewise.
Diffstat (limited to 'libstdc++-v3/include/bits/regex.h')
-rw-r--r-- | libstdc++-v3/include/bits/regex.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h index 31ebcc1eb86..15e4289bf95 100644 --- a/libstdc++-v3/include/bits/regex.h +++ b/libstdc++-v3/include/bits/regex.h @@ -973,11 +973,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 if (const size_t __n = std::min(_M_len, __s._M_len)) if (int __ret = traits_type::compare(_M_data, __s._M_data, __n)) return __ret; + using __limits = __gnu_cxx::__int_traits<int>; const difference_type __diff = _M_len - __s._M_len; - if (__diff > std::numeric_limits<int>::max()) - return std::numeric_limits<int>::max(); - if (__diff < std::numeric_limits<int>::min()) - return std::numeric_limits<int>::min(); + if (__diff > __limits::__max) + return __limits::__max; + if (__diff < __limits::__min) + return __limits::__min; return static_cast<int>(__diff); } |