[libcxx-commits] [libcxx] [libc++] optimization on ranges::drop_view::begin (#72883) (PR #72929)
Will Hawkins via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Dec 14 14:29:36 PST 2023
================
@@ -104,7 +108,8 @@ namespace ranges {
constexpr auto begin() const
requires random_access_range<const _View> && sized_range<const _View>
{
- return ranges::next(ranges::begin(__base_), __count_, ranges::end(__base_));
+ range_difference_t<_View> __dist = ranges::distance(__base_);
+ return ranges::begin(__base_) + std::min(__count_, __dist);
----------------
hawkinsw wrote:
Good catch! I missed the nested `iterator_t` inside the definition of the `range_difference_t`.
And, you're right, that would be evil!
https://github.com/llvm/llvm-project/pull/72929
More information about the libcxx-commits
mailing list