[all-commits] [llvm/llvm-project] 04dbf7: [libc++][ranges] Avoid using `distance` in `ranges...

A. Jiang via All-commits all-commits at lists.llvm.org
Tue Apr 2 17:21:37 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 04dbf7ad44dbe099f8265ad1db38cbf9a0767a82
      https://github.com/llvm/llvm-project/commit/04dbf7ad44dbe099f8265ad1db38cbf9a0767a82
  Author: A. Jiang <de34 at live.cn>
  Date:   2024-04-02 (Tue, 02 Apr 2024)

  Changed paths:
    M libcxx/include/__algorithm/ranges_contains_subrange.h
    M libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains_subrange.pass.cpp

  Log Message:
  -----------
  [libc++][ranges] Avoid using `distance` in `ranges::contains_subrange` (#87155)

Both `std::distance` or `ranges::distance` are inefficient for
non-sized ranges. Also, calculating the range using `int` type is
seriously problematic.

This patch avoids using `distance` and calculation of the length of
non-sized ranges.

Fixes #86833.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list