Skip to content

Conversation

kazutakahirata
Copy link
Contributor

IsSizeLessThanThreshold is used only in AdjustedParamTBase, just a few
lines below the declaration. This patch simplifies
IsSizeLessThanThreshold by substituting U with T, stripping away the
template, and switching to "static constexpr bool.

IsSizeLessThanThreshold is used only in AdjustedParamTBase, just a few
lines below the declaration.  This patch simplifies
IsSizeLessThanThreshold by substituting U with T, stripping away the
template, and switching to "static constexpr bool.
@llvmbot
Copy link
Member

llvmbot commented Sep 25, 2025

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

Changes

IsSizeLessThanThreshold is used only in AdjustedParamTBase, just a few
lines below the declaration. This patch simplifies
IsSizeLessThanThreshold by substituting U with T, stripping away the
template, and switching to "static constexpr bool.


Full diff: https://github.com/llvm/llvm-project/pull/160642.diff

1 Files Affected:

  • (modified) llvm/include/llvm/ADT/FunctionExtras.h (+3-4)
diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h
index 12a2dc36e1af0..2498cb7796f1f 100644
--- a/llvm/include/llvm/ADT/FunctionExtras.h
+++ b/llvm/include/llvm/ADT/FunctionExtras.h
@@ -90,13 +90,12 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
   template <typename T> struct AdjustedParamTBase {
     static_assert(!std::is_reference<T>::value,
                   "references should be handled by template specialization");
-    template <typename U>
-    using IsSizeLessThanThresholdT =
-        std::bool_constant<sizeof(U) <= 2 * sizeof(void *)>;
+    static constexpr bool IsSizeLessThanThreshold =
+        sizeof(T) <= 2 * sizeof(void *);
     using type =
         std::conditional_t<std::is_trivially_copy_constructible<T>::value &&
                                std::is_trivially_move_constructible<T>::value &&
-                               IsSizeLessThanThresholdT<T>::value,
+                               IsSizeLessThanThreshold,
                            T, T &>;
   };
 

@kazutakahirata kazutakahirata merged commit 5953233 into llvm:main Sep 25, 2025
11 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250924_ADT_FunctionExtras_bool branch September 25, 2025 15:53
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Oct 3, 2025
IsSizeLessThanThreshold is used only in AdjustedParamTBase, just a few
lines below the declaration.  This patch simplifies
IsSizeLessThanThreshold by substituting U with T, stripping away the
template, and switching to "static constexpr bool.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants