Skip to content

Commit cb78bf6

Browse files
[ADT] Move IsSizeLessThanThresholdT into AdjustedParamTBase (NFC) (#159900)
This patch moves IsSizeLessThanThresholdT into AdjustedParamTBase, the sole user of the helper, while switching to a type alias. Aside from moving the helper closer to where it's used, another benefit is that we can assume that T is a complete type inside AdjustedParamTBase. Note that sizeof(T) serves as a check for a complete type. Inside AdjustedParamTBase, we only pass complete non-void types to: std::is_trivially_copy_constructible<T> std::is_trivially_move_constructible<T> so we can safely drop the fallback case implemented with std::false_type.
1 parent 941ea28 commit cb78bf6

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

llvm/include/llvm/ADT/FunctionExtras.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,6 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
8282
static constexpr size_t InlineStorageSize = sizeof(void *) * 3;
8383
static constexpr size_t InlineStorageAlign = alignof(void *);
8484

85-
template <typename T, class = void>
86-
struct IsSizeLessThanThresholdT : std::false_type {};
87-
88-
template <typename T>
89-
struct IsSizeLessThanThresholdT<
90-
T, std::enable_if_t<sizeof(T) <= 2 * sizeof(void *)>> : std::true_type {};
91-
9285
// Provide a type function to map parameters that won't observe extra copies
9386
// or moves and which are small enough to likely pass in register to values
9487
// and all other types to l-value reference types. We use this to compute the
@@ -101,6 +94,9 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
10194
template <typename T> struct AdjustedParamTBase {
10295
static_assert(!std::is_reference<T>::value,
10396
"references should be handled by template specialization");
97+
template <typename U>
98+
using IsSizeLessThanThresholdT =
99+
std::bool_constant<sizeof(U) <= 2 * sizeof(void *)>;
104100
using type =
105101
std::conditional_t<std::is_trivially_copy_constructible<T>::value &&
106102
std::is_trivially_move_constructible<T>::value &&

0 commit comments

Comments
 (0)