mirror of
https://github.com/greg7mdp/parallel-hashmap.git
synced 2026-08-29 16:40:39 +08:00
cleanup some warnings
This commit is contained in:
Vendored
+2
-2
@@ -1197,10 +1197,10 @@ namespace container_internal {
|
||||
void clear_child(size_type i) {
|
||||
phmap::container_internal::SanitizerPoisonObject(&mutable_child(i));
|
||||
}
|
||||
void set_child(int i, btree_node *c) {
|
||||
void set_child(size_type i, btree_node *c) {
|
||||
phmap::container_internal::SanitizerUnpoisonObject(&mutable_child(i));
|
||||
mutable_child(i) = c;
|
||||
c->set_position(i);
|
||||
c->set_position((field_type)i);
|
||||
}
|
||||
void init_child(int i, btree_node *c) {
|
||||
set_child(i, c);
|
||||
|
||||
Vendored
+25
-4
@@ -55,6 +55,12 @@
|
||||
#include <string_view>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
// warning C4820: '6' bytes padding added after data member
|
||||
#pragma warning(disable : 4820)
|
||||
#endif
|
||||
|
||||
namespace phmap {
|
||||
|
||||
namespace container_internal {
|
||||
@@ -268,7 +274,7 @@ inline size_t H1(size_t hash, const ctrl_t* ) {
|
||||
#endif
|
||||
|
||||
|
||||
inline ctrl_t H2(size_t hash) { return hash & 0x7F; }
|
||||
inline ctrl_t H2(size_t hash) { return (ctrl_t)(hash & 0x7F); }
|
||||
|
||||
inline bool IsEmpty(ctrl_t c) { return c == kEmpty; }
|
||||
inline bool IsFull(ctrl_t c) { return c >= 0; }
|
||||
@@ -313,7 +319,7 @@ struct GroupSse2Impl
|
||||
// Returns a bitmask representing the positions of slots that match hash.
|
||||
// ----------------------------------------------------------------------
|
||||
BitMask<uint32_t, kWidth> Match(h2_t hash) const {
|
||||
auto match = _mm_set1_epi8(hash);
|
||||
auto match = _mm_set1_epi8((char)hash);
|
||||
return BitMask<uint32_t, kWidth>(
|
||||
_mm_movemask_epi8(_mm_cmpeq_epi8(match, ctrl)));
|
||||
}
|
||||
@@ -461,6 +467,12 @@ inline size_t NormalizeCapacity(size_t n)
|
||||
return n ? ~size_t{} >> LeadingZeros(n) : 1;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
// warning C4127: conditional expression is constant
|
||||
#pragma warning(disable : 4127)
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// We use 7/8th as maximum load factor.
|
||||
// For 16-wide groups, that gives an average of two empty slots per group.
|
||||
@@ -469,7 +481,7 @@ inline size_t CapacityToGrowth(size_t capacity)
|
||||
{
|
||||
assert(IsValidCapacity(capacity));
|
||||
// `capacity*7/8`
|
||||
if (Group::kWidth == 8 && capacity == 7) {
|
||||
PHMAP_IF_CONSTEXPR (Group::kWidth == 8 && capacity == 7) {
|
||||
// x-x/8 does not work when x==7.
|
||||
return 6;
|
||||
}
|
||||
@@ -483,13 +495,17 @@ inline size_t CapacityToGrowth(size_t capacity)
|
||||
inline size_t GrowthToLowerboundCapacity(size_t growth)
|
||||
{
|
||||
// `growth*8/7`
|
||||
if (Group::kWidth == 8 && growth == 7) {
|
||||
PHMAP_IF_CONSTEXPR (Group::kWidth == 8 && growth == 7) {
|
||||
// x+(x-1)/7 does not work when x==7.
|
||||
return 8;
|
||||
}
|
||||
return growth + static_cast<size_t>((static_cast<int64_t>(growth) - 1) / 7);
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
namespace hashtable_debug_internal {
|
||||
|
||||
// If it is a map, call get<0>().
|
||||
@@ -4347,4 +4363,9 @@ public:
|
||||
|
||||
} // namespace phmap
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
|
||||
#endif // phmap_h_guard_
|
||||
|
||||
Vendored
+26
-13
@@ -246,17 +246,6 @@ struct is_trivially_destructible
|
||||
: std::integral_constant<bool, __has_trivial_destructor(T) &&
|
||||
std::is_destructible<T>::value>
|
||||
{
|
||||
#ifdef PHMAP_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
|
||||
private:
|
||||
static constexpr bool compliant = std::is_trivially_destructible<T>::value ==
|
||||
is_trivially_destructible::value;
|
||||
static_assert(compliant || std::is_trivially_destructible<T>::value,
|
||||
"Not compliant with std::is_trivially_destructible; "
|
||||
"Standard: false, Implementation: true");
|
||||
static_assert(compliant || !std::is_trivially_destructible<T>::value,
|
||||
"Not compliant with std::is_trivially_destructible; "
|
||||
"Standard: true, Implementation: false");
|
||||
#endif
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -2846,6 +2835,12 @@ struct KeyArg<false>
|
||||
using type = key_type;
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
// warning C4820: '6' bytes padding added after data member
|
||||
#pragma warning(disable : 4820)
|
||||
#endif
|
||||
|
||||
// The node_handle concept from C++17.
|
||||
// We specialize node_handle for sets and maps. node_handle_base holds the
|
||||
// common API of both.
|
||||
@@ -2900,6 +2895,9 @@ protected:
|
||||
PolicyTraits::transfer(alloc(), slot(), s);
|
||||
}
|
||||
|
||||
node_handle_base(const node_handle_base&) = delete;
|
||||
node_handle_base& operator=(const node_handle_base&) = delete;
|
||||
|
||||
void destroy() {
|
||||
if (!empty()) {
|
||||
PolicyTraits::destroy(alloc(), slot());
|
||||
@@ -2921,10 +2919,13 @@ protected:
|
||||
|
||||
private:
|
||||
phmap::optional<allocator_type> alloc_;
|
||||
mutable phmap::aligned_storage_t<sizeof(slot_type), alignof(slot_type)>
|
||||
slot_space_;
|
||||
mutable phmap::aligned_storage_t<sizeof(slot_type), alignof(slot_type)> slot_space_;
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
// For sets.
|
||||
// ---------
|
||||
template <typename Policy, typename PolicyTraits, typename Alloc,
|
||||
@@ -4436,6 +4437,11 @@ class PHMAP_INTERNAL_COMPRESSED_TUPLE_DECLSPEC CompressedTuple<> {};
|
||||
namespace phmap {
|
||||
namespace container_internal {
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
// warning warning C4324: structure was padded due to alignment specifier
|
||||
#pragma warning(disable : 4324)
|
||||
#endif
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -4477,6 +4483,10 @@ void Deallocate(Alloc* alloc, void* p, size_t n) {
|
||||
(n + sizeof(M) - 1) / sizeof(M));
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
// Helper functions for asan and msan.
|
||||
// ----------------------------------------------------------------------------
|
||||
inline void SanitizerPoisonMemoryRegion(const void* m, size_t s) {
|
||||
@@ -4714,6 +4724,9 @@ union map_slot_type
|
||||
{
|
||||
map_slot_type() {}
|
||||
~map_slot_type() = delete;
|
||||
map_slot_type(const map_slot_type&) = delete;
|
||||
map_slot_type& operator=(const map_slot_type&) = delete;
|
||||
|
||||
using value_type = std::pair<const K, V>;
|
||||
using mutable_value_type = std::pair<K, V>;
|
||||
|
||||
|
||||
Vendored
+4
-4
@@ -279,7 +279,7 @@ PHMAP_BASE_INTERNAL_FORCEINLINE int CountLeadingZeros64(uint64_t n) {
|
||||
// MSVC does not have __buitin_clzll. Use _BitScanReverse64.
|
||||
unsigned long result = 0; // NOLINT(runtime/int)
|
||||
if (_BitScanReverse64(&result, n)) {
|
||||
return 63 - result;
|
||||
return (int)(63 - result);
|
||||
}
|
||||
return 64;
|
||||
#elif defined(_MSC_VER)
|
||||
@@ -322,7 +322,7 @@ PHMAP_BASE_INTERNAL_FORCEINLINE int CountLeadingZeros32(uint32_t n) {
|
||||
#if defined(_MSC_VER)
|
||||
unsigned long result = 0; // NOLINT(runtime/int)
|
||||
if (_BitScanReverse(&result, n)) {
|
||||
return 31 - result;
|
||||
return (int)(31 - result);
|
||||
}
|
||||
return 32;
|
||||
#elif defined(__GNUC__)
|
||||
@@ -359,7 +359,7 @@ PHMAP_BASE_INTERNAL_FORCEINLINE int CountTrailingZerosNonZero64(uint64_t n) {
|
||||
#if defined(_MSC_VER) && defined(_M_X64)
|
||||
unsigned long result = 0; // NOLINT(runtime/int)
|
||||
_BitScanForward64(&result, n);
|
||||
return result;
|
||||
return (int)result;
|
||||
#elif defined(_MSC_VER)
|
||||
unsigned long result = 0; // NOLINT(runtime/int)
|
||||
if (static_cast<uint32_t>(n) == 0) {
|
||||
@@ -392,7 +392,7 @@ PHMAP_BASE_INTERNAL_FORCEINLINE int CountTrailingZerosNonZero32(uint32_t n) {
|
||||
#if defined(_MSC_VER)
|
||||
unsigned long result = 0; // NOLINT(runtime/int)
|
||||
_BitScanForward(&result, n);
|
||||
return result;
|
||||
return (int)result;
|
||||
#elif defined(__GNUC__)
|
||||
static_assert(sizeof(int) == sizeof(n),
|
||||
"__builtin_ctz does not take 32-bit arg");
|
||||
|
||||
Vendored
+9
@@ -627,6 +627,15 @@
|
||||
#endif
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// constexpr if
|
||||
// ----------------------------------------------------------------------
|
||||
#if __cplusplus >= 201703 || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703)
|
||||
#define PHMAP_IF_CONSTEXPR(expr) if constexpr ((expr))
|
||||
#else
|
||||
#define PHMAP_IF_CONSTEXPR(expr) if ((expr))
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// base/macros.h
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user