perf: get_kind_tree_root result caching added

This commit is contained in:
Mateusz Pusz
2024-11-16 22:03:55 +01:00
parent 049a5a434a
commit 07497ce2c5

View File

@@ -1476,7 +1476,7 @@ template<typename Self, NamedQuantitySpec auto QS, auto... Args>
}
template<QuantitySpec Q>
[[nodiscard]] consteval QuantitySpec auto get_kind_tree_root(Q q)
[[nodiscard]] consteval QuantitySpec auto get_kind_tree_root_impl(Q q)
{
auto defined_as_kind = []<typename QQ>(QQ qq) {
if constexpr (requires { defined_as_kind_impl(qq); })
@@ -1501,6 +1501,15 @@ template<QuantitySpec Q>
// NOLINTEND(bugprone-branch-clone)
}
template<QuantitySpec Q>
constexpr QuantitySpec auto get_kind_tree_root_result = get_kind_tree_root_impl(Q{});
template<QuantitySpec Q>
[[nodiscard]] consteval QuantitySpec auto get_kind_tree_root(Q)
{
return get_kind_tree_root_result<Q>;
}
} // namespace detail
MP_UNITS_EXPORT_BEGIN