[libcxx-commits] [libcxx] [libc++] Optimize ranges::{for_each, for_each_n} for segmented iterators (PR #132896)
Peng Liu via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Apr 5 07:11:50 PDT 2025
winner245 wrote:
> I feel like the scope of this patch is getting a bit out of hand. The title says that you're optimizing `ranges::for_each{,_n}`, but you're also back-porting the `std::for_each` optimization to C++03, adding and adding an optimization to `std::for_each_n`. Could we split this up to make it clear what changes are required for what optimizations? Also, why do we want to back-port the `std::for_each` optimization now? Do we think the extra complexity is worth the improved performance?
Thank you for your feedback! I agree that the scoped of the patch has expanded beyond it original intent. Initially, the goal was simple: only to extend the optimization for `std::for_each` to its variants `ranges::for_each{,_n}`. However, as the review and revision progressed, I aimed to address the inconsistent segmented iterator optimization support between `for_each_n` and `for_each`, as the optimization for `for_each_n` includes C++03. I think back-porting the optimization for `std::for_each` to C++03 could be useful as we may be able to extend the optimization to other algorithms by letting them simply forward to `std::for_each` (as per your [comment](https://github.com/llvm/llvm-project/pull/132665#discussion_r2012150342) in another PR).
However, I agree that this made the patch diverge from its original purpose and may complicate the review process. Following your suggestion, I will work on splitting it to make it clear what this patch focuses on.
https://github.com/llvm/llvm-project/pull/132896
More information about the libcxx-commits
mailing list