[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:17:27 PDT 2026


higher-performance wrote:

@philnik777 I think I made a partial mistake, though not quite regarding it being quadratic.

The _compile_ time (not execution time) of the existing code is at least quadratic due to `std::get` itself being linear-time. This is non-obvious and AFAICT it's due to the expansion of `T...` in the `tuple<T...>` signature, which forces it to take linear time. I could be mistaken on the precise reason, but the timing is easy enough to check.

I somehow thought `std::tuple_size` was _also_ quadratic for a similar reason (hence eliminating it in this PR), but I can't show that being the case now, so I've reverted that aspect of the change.

In any case, reducing the number of calls to `std::get` itself speeds up compilation a fair bit (reducing it by ~20% in my testing), so I'm simplifying this PR to just doing that.

https://github.com/llvm/llvm-project/pull/214646


More information about the libcxx-commits mailing list