Skip to content

Commit

Permalink
Sync phmap
Browse files Browse the repository at this point in the history
  • Loading branch information
fcharlie committed Jun 25, 2023
1 parent 4077dee commit d09bcd8
Show file tree
Hide file tree
Showing 9 changed files with 234 additions and 419 deletions.
2 changes: 1 addition & 1 deletion include/bela/__phmap/VERSION
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
https://github.com/greg7mdp/parallel-hashmap.git
ab663358bc7aea9434b5652e07188d944d386eb5
79cbd2dafd5aab3829064d1b48b71137623d8ff2
55 changes: 22 additions & 33 deletions include/bela/__phmap/btree.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include <cstring>
#include <limits>
#include <new>
#include <type_traits>

#include "phmap_fwd_decl.h"
#include "phmap_base.h"
Expand All @@ -76,14 +77,6 @@

namespace phmap {

// Defined and documented later on in this file.
template <typename T>
struct is_trivially_destructible;

// Defined and documented later on in this file.
template <typename T>
struct is_trivially_move_assignable;

namespace type_traits_internal {

// Silence MSVC warnings about the destructor being defined as deleted.
Expand All @@ -107,25 +100,25 @@ namespace phmap {
: std::integral_constant<
bool, std::is_move_constructible<
type_traits_internal::SingleMemberUnion<T>>::value &&
phmap::is_trivially_destructible<T>::value> {};
std::is_trivially_destructible<T>::value> {};

template <class T>
struct IsTriviallyCopyConstructibleObject
: std::integral_constant<
bool, std::is_copy_constructible<
type_traits_internal::SingleMemberUnion<T>>::value &&
phmap::is_trivially_destructible<T>::value> {};
std::is_trivially_destructible<T>::value> {};

template <class T>
struct IsTriviallyMoveAssignableReference : std::false_type {};

template <class T>
struct IsTriviallyMoveAssignableReference<T&>
: phmap::is_trivially_move_assignable<T>::type {};
: std::is_trivially_move_assignable<T>::type {};

template <class T>
struct IsTriviallyMoveAssignableReference<T&&>
: phmap::is_trivially_move_assignable<T>::type {};
: std::is_trivially_move_assignable<T>::type {};

} // namespace type_traits_internal

Expand Down Expand Up @@ -155,10 +148,10 @@ namespace phmap {

public:
static constexpr bool kValue =
(__has_trivial_copy(ExtentsRemoved) || !kIsCopyOrMoveConstructible) &&
(__has_trivial_assign(ExtentsRemoved) || !kIsCopyOrMoveAssignable) &&
(std::is_trivially_copyable<ExtentsRemoved>::value || !kIsCopyOrMoveConstructible) &&
(std::is_trivially_copy_assignable<ExtentsRemoved>::value || !kIsCopyOrMoveAssignable) &&
(kIsCopyOrMoveConstructible || kIsCopyOrMoveAssignable) &&
is_trivially_destructible<ExtentsRemoved>::value &&
std::is_trivially_destructible<ExtentsRemoved>::value &&
// We need to check for this explicitly because otherwise we'll say
// references are trivial copyable when compiled by MSVC.
!std::is_reference<ExtentsRemoved>::value;
Expand Down Expand Up @@ -744,13 +737,13 @@ namespace priv {
StringBtreeDefaultLess(std::less<std::string_view>) {} // NOLINT
StringBtreeDefaultLess(phmap::Less<std::string_view>) {} // NOLINT

phmap::weak_ordering operator()(std::string_view lhs,
std::string_view rhs) const {
phmap::weak_ordering operator()(const std::string_view &lhs,
const std::string_view &rhs) const {
return compare_internal::compare_result_as_ordering(lhs.compare(rhs));
}
#else
phmap::weak_ordering operator()(std::string lhs,
std::string rhs) const {
phmap::weak_ordering operator()(const std::string &lhs,
const std::string &rhs) const {
return compare_internal::compare_result_as_ordering(lhs.compare(rhs));
}
#endif
Expand All @@ -770,8 +763,8 @@ namespace priv {
return compare_internal::compare_result_as_ordering(rhs.compare(lhs));
}
#else
phmap::weak_ordering operator()(std::string lhs,
std::string rhs) const {
phmap::weak_ordering operator()(const std::string &lhs,
const std::string &rhs) const {
return compare_internal::compare_result_as_ordering(rhs.compare(lhs));
}
#endif
Expand Down Expand Up @@ -1868,7 +1861,7 @@ namespace priv {
void swap(btree &x);

const key_compare &key_comp() const noexcept {
return root_.template get<0>();
return std::get<0>(root_);
}
template <typename K, typename LK>
bool compare_keys(const K &x, const LK &y) const {
Expand Down Expand Up @@ -1961,21 +1954,21 @@ namespace priv {

private:
// Internal accessor routines.
node_type *root() { return root_.template get<2>(); }
const node_type *root() const { return root_.template get<2>(); }
node_type *&mutable_root() noexcept { return root_.template get<2>(); }
key_compare *mutable_key_comp() noexcept { return &root_.template get<0>(); }
node_type *root() { return std::get<2>(root_); }
const node_type *root() const { return std::get<2>(root_); }
node_type *&mutable_root() noexcept { return std::get<2>(root_); }
key_compare *mutable_key_comp() noexcept { return &std::get<0>(root_); }

// The leftmost node is stored as the parent of the root node.
node_type *leftmost() { return root()->parent(); }
const node_type *leftmost() const { return root()->parent(); }

// Allocator routines.
allocator_type *mutable_allocator() noexcept {
return &root_.template get<1>();
return &std::get<1>(root_);
}
const allocator_type &allocator() const noexcept {
return root_.template get<1>();
return std::get<1>(root_);
}

// Allocates a correctly aligned node of at least size bytes using the
Expand Down Expand Up @@ -2117,11 +2110,7 @@ namespace priv {
}

private:
// We use compressed tuple in order to save space because key_compare and
// allocator_type are usually empty.
phmap::priv::CompressedTuple<key_compare, allocator_type,
node_type *>
root_;
std::tuple<key_compare, allocator_type, node_type *> root_;

// A pointer to the rightmost node. Note that the leftmost node is stored as
// the root's parent.
Expand Down

0 comments on commit d09bcd8

Please sign in to comment.