Saleem Abdulrasool: Silence warning and reduce unnecessary code in hash.cpp.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@171167 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant 2012-12-27 18:59:05 +00:00
parent c6e54b964f
commit 0aa900e94f

View File

@ -10,6 +10,10 @@
#include "__hash_table" #include "__hash_table"
#include "algorithm" #include "algorithm"
#include "stdexcept" #include "stdexcept"
#include "type_traits"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
@ -144,21 +148,23 @@ const unsigned indices[] =
// are fewer potential primes to search, and fewer potential primes to divide // are fewer potential primes to search, and fewer potential primes to divide
// against. // against.
template <size_t _Sz = sizeof(size_t)>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
void typename enable_if<_Sz == 4, void>::type
__check_for_overflow(size_t N, integral_constant<size_t, 32>) __check_for_overflow(size_t N)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS #ifndef _LIBCPP_NO_EXCEPTIONS
if (N > 0xFFFFFFFB) if (N > 0xFFFFFFFB)
throw overflow_error("__next_prime overflow"); throw overflow_error("__next_prime overflow");
#endif #endif
} }
template <size_t _Sz = sizeof(size_t)>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
void typename enable_if<_Sz == 8, void>::type
__check_for_overflow(size_t N, integral_constant<size_t, 64>) __check_for_overflow(size_t N)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS #ifndef _LIBCPP_NO_EXCEPTIONS
if (N > 0xFFFFFFFFFFFFFFC5ull) if (N > 0xFFFFFFFFFFFFFFC5ull)
throw overflow_error("__next_prime overflow"); throw overflow_error("__next_prime overflow");
#endif #endif
@ -174,8 +180,7 @@ __next_prime(size_t n)
return *std::lower_bound(small_primes, small_primes + N, n); return *std::lower_bound(small_primes, small_primes + N, n);
// Else n > largest small_primes // Else n > largest small_primes
// Check for overflow // Check for overflow
__check_for_overflow(n, integral_constant<size_t, __check_for_overflow(n);
sizeof(n) * __CHAR_BIT__>());
// Start searching list of potential primes: L * k0 + indices[in] // Start searching list of potential primes: L * k0 + indices[in]
const size_t M = sizeof(indices) / sizeof(indices[0]); const size_t M = sizeof(indices) / sizeof(indices[0]);
// Select first potential prime >= n // Select first potential prime >= n