[libcxx-commits] [libcxx] [libc++] Optimize ranges::for_each for iterating over __trees (PR #164405)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Oct 22 08:10:57 PDT 2025
================
@@ -717,6 +718,59 @@ private:
friend class __tree_const_iterator;
};
+template <class _Reference, class _EndNodePtr, class _NodePtr, class _Func, class _Proj>
+_LIBCPP_HIDE_FROM_ABI bool __tree_iterate_from_root(_EndNodePtr __last, _NodePtr __root, _Func& __func, _Proj& __proj) {
----------------
ldionne wrote:
This could take a predicate called something like `_EarlyExit` or `_Break` or something like that. And then `__tree_iterate_from_begin` can call that with `[](auto node) { return node == last; }`.
And the `ranges::for_each` implementation can just use `__tree_iterate_from_root([](auto) { return false; })`.
https://github.com/llvm/llvm-project/pull/164405
More information about the libcxx-commits
mailing list