[libcxx-commits] [libcxx] [libc++] optimization on ranges::drop_view::begin (#72883) (PR #72929)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Nov 21 11:49:25 PST 2023


================
@@ -90,6 +90,10 @@ namespace ranges {
       requires (!(__simple_view<_View> &&
                   random_access_range<const _View> && sized_range<const _View>))
     {
+      if constexpr (random_access_range<const _View> && sized_range<const _View>) {
+        auto __dist = ranges::distance(__base_);
+        return ranges::begin(__base_) + std::min<range_difference_t<_View>>(__count_, __dist);
----------------
huixie90 wrote:

I think you don’t need to explicit template parameter here because they are the same type.  If you want clarity, I would replace the ‘auto’ above with range_difference_t

https://github.com/llvm/llvm-project/pull/72929


More information about the libcxx-commits mailing list