[libcxx-commits] [libcxx] Speed up pre-C++20 operator<(std::tuple, std::tuple) (PR #214646)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Aug 15 05:16:01 PDT 2026
https://github.com/higher-performance updated https://github.com/llvm/llvm-project/pull/214646
>From 47d915d9211a0d6798eb373c8b25f3b6c04b1cb2 Mon Sep 17 00:00:00 2001
From: higher-performance <higher.performance.github at gmail.com>
Date: Fri, 7 Aug 2026 02:33:01 -0400
Subject: [PATCH] Speed up the compile time of C++17 operator<(std::tuple,
std::tuple)
---
libcxx/include/tuple | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libcxx/include/tuple b/libcxx/include/tuple
index 2f0127bc7388d..10eedff903d16 100644
--- a/libcxx/include/tuple
+++ b/libcxx/include/tuple
@@ -1196,9 +1196,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