Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 20 additions & 26 deletions llvm/include/llvm/ADT/DenseMapInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,41 +179,35 @@ template <typename... Ts> struct DenseMapInfo<std::tuple<Ts...>> {
return Tuple(DenseMapInfo<Ts>::getTombstoneKey()...);
}

template <unsigned I>
static unsigned getHashValueImpl(const Tuple &values, std::false_type) {
using EltType = std::tuple_element_t<I, Tuple>;
std::integral_constant<bool, I + 1 == sizeof...(Ts)> atEnd;
return detail::combineHashValue(
DenseMapInfo<EltType>::getHashValue(std::get<I>(values)),
getHashValueImpl<I + 1>(values, atEnd));
}

template <unsigned I>
static unsigned getHashValueImpl(const Tuple &, std::true_type) {
return 0;
template <unsigned I> static unsigned getHashValueImpl(const Tuple &values) {
if constexpr (I == sizeof...(Ts))
return 0;
else {
using EltType = std::tuple_element_t<I, Tuple>;
return detail::combineHashValue(
DenseMapInfo<EltType>::getHashValue(std::get<I>(values)),
getHashValueImpl<I + 1>(values));
}
}

static unsigned getHashValue(const std::tuple<Ts...> &values) {
std::integral_constant<bool, 0 == sizeof...(Ts)> atEnd;
return getHashValueImpl<0>(values, atEnd);
return getHashValueImpl<0>(values);
}

template <unsigned I>
static bool isEqualImpl(const Tuple &lhs, const Tuple &rhs, std::false_type) {
using EltType = std::tuple_element_t<I, Tuple>;
std::integral_constant<bool, I + 1 == sizeof...(Ts)> atEnd;
return DenseMapInfo<EltType>::isEqual(std::get<I>(lhs), std::get<I>(rhs)) &&
isEqualImpl<I + 1>(lhs, rhs, atEnd);
}

template <unsigned I>
static bool isEqualImpl(const Tuple &, const Tuple &, std::true_type) {
return true;
static bool isEqualImpl(const Tuple &lhs, const Tuple &rhs) {
if constexpr (I == sizeof...(Ts))
return true;
else {
using EltType = std::tuple_element_t<I, Tuple>;
return DenseMapInfo<EltType>::isEqual(std::get<I>(lhs),
std::get<I>(rhs)) &&
isEqualImpl<I + 1>(lhs, rhs);
}
}

static bool isEqual(const Tuple &lhs, const Tuple &rhs) {
std::integral_constant<bool, 0 == sizeof...(Ts)> atEnd;
return isEqualImpl<0>(lhs, rhs, atEnd);
return isEqualImpl<0>(lhs, rhs);
}
};

Expand Down