-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc++] Simplify the implementation of __next_prime a bit #143512
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
Conversation
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesFull diff: https://github.com/llvm/llvm-project/pull/143512.diff 1 Files Affected:
diff --git a/libcxx/src/hash.cpp b/libcxx/src/hash.cpp
index 41c4eb480a5fc..50d8cf9f9f539 100644
--- a/libcxx/src/hash.cpp
+++ b/libcxx/src/hash.cpp
@@ -9,7 +9,6 @@
#include <__hash_table>
#include <algorithm>
#include <stdexcept>
-#include <type_traits>
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wtautological-constant-out-of-range-compare")
@@ -52,16 +51,15 @@ const unsigned indices[] = {
// are fewer potential primes to search, and fewer potential primes to divide
// against.
-template <size_t _Sz = sizeof(size_t)>
-inline _LIBCPP_HIDE_FROM_ABI typename enable_if<_Sz == 4, void>::type __check_for_overflow(size_t N) {
- if (N > 0xFFFFFFFB)
- std::__throw_overflow_error("__next_prime overflow");
-}
-
-template <size_t _Sz = sizeof(size_t)>
-inline _LIBCPP_HIDE_FROM_ABI typename enable_if<_Sz == 8, void>::type __check_for_overflow(size_t N) {
- if (N > 0xFFFFFFFFFFFFFFC5ull)
- std::__throw_overflow_error("__next_prime overflow");
+inline void __check_for_overflow(size_t N) {
+ if constexpr (sizeof(size_t) == 4) {
+ if (N > 0xFFFFFFFB)
+ std::__throw_overflow_error("__next_prime overflow");
+ } else {
+ static_assert(sizeof(size_t) == 8);
+ if (N > 0xFFFFFFFFFFFFFFC5ull)
+ std::__throw_overflow_error("__next_prime overflow");
+ }
}
size_t __next_prime(size_t n) {
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/123/builds/21150 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/10/builds/7140 Here is the relevant piece of the build log for the reference
|
No description provided.