[libcxx-commits] [libcxx] [libc++] optimization on ranges::drop_view::begin (#72883) (PR #72929)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Dec 13 03:17:09 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);
----------------
huixie90 wrote:
super nit:
the type of `(__count_)` is `range_difference_t<_View> const&` and the type of `(__dist)` is `range_difference_t<const _View> &` and I am not sure `range_difference_t<_View>` and `range_difference_t<const _View>` have to be the same type.
https://github.com/llvm/llvm-project/pull/72929
More information about the libcxx-commits
mailing list