[libcxx-commits] [PATCH] D151274: [libc++] Optimize for_each for segmented iterators
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed May 24 10:14:05 PDT 2023
Mordante added a comment.
In D151274#4366483 <https://reviews.llvm.org/D151274#4366483>, @philnik wrote:
> Benchmark numbers:
Can you put these numbers in the commit message? That way we can be certain they will be preserved even when Phab ever disappears.
> This is only optimized for C++20-and-later as-is. The question is whether that is OK for the library. The implementation is a lot easier, but we essentially say "use the latest C++ version or you don't get nice optimizations".
I'm totally fine with that. If it's easy to backport the changes without ugly code that would be great, otherwise let's not do it.
In 10 years we still need to maintain this code and most users have probably moved to C++20 or later.
================
Comment at: libcxx/include/__algorithm/for_each.h:33
+#if _LIBCPP_STD_VER >= 20
+template <class _SegmentedIterator, class _Function>
----------------
ldionne wrote:
> I am fine with only optimizing this in C++20. This is QOI and we should be pushing folks towards newer Standards.
+1
================
Comment at: libcxx/include/__algorithm/for_each.h:38
+for_each(_SegmentedIterator __first, _SegmentedIterator __last, _Function __func) {
+ std::__for_each_segment(__first, __last, [&](auto __lfirst, auto __llast) {
+ __func = std::for_each(__lfirst, __llast, std::move(__func));
----------------
Seems this answers my lambda question in the other review ;-)
================
Comment at: libcxx/include/__algorithm/for_each.h:43
+}
+#endif // _LIBCPP_STD_VER >= 14
+
----------------
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151274/new/
https://reviews.llvm.org/D151274
More information about the libcxx-commits
mailing list