Skip to content

Commit 2b660b0

Browse files
author
git apple-llvm automerger
committed
Merge commit '30e77152961b' from llvm.org/main into next
2 parents 6ac0ba3 + 30e7715 commit 2b660b0

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

llvm/include/llvm/ADT/SparseSet.h

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,20 @@ template <typename ValueT> struct SparseSetValTraits {
5959
}
6060
};
6161

62-
/// SparseSetValFunctor - Helper class for selecting SparseSetValTraits. The
63-
/// generic implementation handles ValueT classes which either provide
64-
/// getSparseSetIndex() or specialize SparseSetValTraits<>.
62+
/// SparseSetValFunctor - Helper class for getting a value's index.
6563
///
64+
/// In the generic case, this is done via SparseSetValTraits. When the value
65+
/// type is the same as the key type, the KeyFunctor is used directly.
6666
template <typename KeyT, typename ValueT, typename KeyFunctorT>
6767
struct SparseSetValFunctor {
6868
unsigned operator()(const ValueT &Val) const {
69-
return SparseSetValTraits<ValueT>::getValIndex(Val);
69+
if constexpr (std::is_same_v<KeyT, ValueT>)
70+
return KeyFunctorT()(Val);
71+
else
72+
return SparseSetValTraits<ValueT>::getValIndex(Val);
7073
}
7174
};
7275

73-
/// SparseSetValFunctor<KeyT, KeyT> - Helper class for the common case of
74-
/// identity key/value sets.
75-
template <typename KeyT, typename KeyFunctorT>
76-
struct SparseSetValFunctor<KeyT, KeyT, KeyFunctorT> {
77-
unsigned operator()(const KeyT &Key) const { return KeyFunctorT()(Key); }
78-
};
79-
8076
/// SparseSet - Fast set implementation for objects that can be identified by
8177
/// small unsigned keys.
8278
///

0 commit comments

Comments
 (0)