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
18 changes: 7 additions & 11 deletions llvm/include/llvm/ADT/SparseSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,20 @@ template <typename ValueT> struct SparseSetValTraits {
}
};

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

/// SparseSetValFunctor<KeyT, KeyT> - Helper class for the common case of
/// identity key/value sets.
template <typename KeyT, typename KeyFunctorT>
struct SparseSetValFunctor<KeyT, KeyT, KeyFunctorT> {
unsigned operator()(const KeyT &Key) const { return KeyFunctorT()(Key); }
};

/// SparseSet - Fast set implementation for objects that can be identified by
/// small unsigned keys.
///
Expand Down