[libcxx-commits] [libcxx] 6eeabb9 - Speed up pre-C++20 operator<(std::tuple, std::tuple) (#214646)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Aug 28 06:58:31 PDT 2026
Author: higher-performance
Date: 2026-08-28T09:58:26-04:00
New Revision: 6eeabb90edaf78dc87aab3caf71eb8facf2b813e
URL: https://github.com/llvm/llvm-project/commit/6eeabb90edaf78dc87aab3caf71eb8facf2b813e
DIFF: https://github.com/llvm/llvm-project/commit/6eeabb90edaf78dc87aab3caf71eb8facf2b813e.diff
LOG: Speed up pre-C++20 operator<(std::tuple, std::tuple) (#214646)
Reduces the compile time of `operator<` for tuples, as `std::get` appears slow to compile.
Added:
Modified:
libcxx/include/tuple
Removed:
################################################################################
diff --git a/libcxx/include/tuple b/libcxx/include/tuple
index 67fd59b07c3e1..03ff3ef36ee1a 100644
--- a/libcxx/include/tuple
+++ b/libcxx/include/tuple
@@ -1192,9 +1192,11 @@ struct __tuple_less {
template <class _Tp, class _Up>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _Tp& __x, const _Up& __y) {
const size_t __idx = tuple_size<_Tp>::value - _Ip;
- if (std::get<__idx>(__x) < std::get<__idx>(__y))
+ const auto& __a = std::get<__idx>(__x);
+ const auto& __b = std::get<__idx>(__y);
+ if (__a < __b)
return true;
- if (std::get<__idx>(__y) < std::get<__idx>(__x))
+ if (__b < __a)
return false;
return __tuple_less<_Ip - 1>()(__x, __y);
}
More information about the libcxx-commits
mailing list