[libcxx-commits] [libcxx] [libc++] Optimize std::find for segmented iterators (PR #67224)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Nov 24 12:47:47 PST 2023


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 95dcb8b49dd3bb0fcb9f020fe931632a0ddf4994 015f9df72b856aac5bf82af767910f63525fe2e8 -- libcxx/include/__algorithm/find_segment_if.h libcxx/benchmarks/algorithms/find.bench.cpp libcxx/include/__algorithm/find.h libcxx/include/deque libcxx/test/libcxx/algorithms/ranges_robust_against_copying_comparators.pass.cpp libcxx/test/libcxx/algorithms/ranges_robust_against_copying_projections.pass.cpp libcxx/test/std/algorithms/alg.nonmodifying/alg.find/find.pass.cpp libcxx/test/std/algorithms/alg.nonmodifying/alg.find/ranges.find.pass.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/test/libcxx/algorithms/ranges_robust_against_copying_projections.pass.cpp b/libcxx/test/libcxx/algorithms/ranges_robust_against_copying_projections.pass.cpp
index 64019273d5..3dfbd600a9 100644
--- a/libcxx/test/libcxx/algorithms/ranges_robust_against_copying_projections.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/ranges_robust_against_copying_projections.pass.cpp
@@ -226,19 +226,19 @@ constexpr bool all_the_algorithms()
 }
 
 void test_deque() {
-    std::deque<T> d;
-    int copies = 0;
-    void* value = nullptr;
+  std::deque<T> d;
+  int copies  = 0;
+  void* value = nullptr;
 
-    (void)std::ranges::find(d, value, Proj(&copies));
-    assert(copies == 0);
+  (void)std::ranges::find(d, value, Proj(&copies));
+  assert(copies == 0);
 }
 
 int main(int, char**)
 {
-    test_deque();
-    all_the_algorithms();
-    static_assert(all_the_algorithms());
+  test_deque();
+  all_the_algorithms();
+  static_assert(all_the_algorithms());
 
-    return 0;
+  return 0;
 }
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find/find.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find/find.pass.cpp
index b598ce096a..b77be215c8 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find/find.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find/find.pass.cpp
@@ -169,7 +169,7 @@ TEST_CONSTEXPR_CXX20 bool test() {
 #if TEST_STD_VER >= 20
   {
     std::vector<std::vector<int>> vec = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
-    auto view = vec | std::views::join;
+    auto view                         = vec | std::views::join;
     assert(std::find(view.begin(), view.end(), 4) == std::next(view.begin(), 3));
   }
 #endif
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find/ranges.find.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find/ranges.find.pass.cpp
index 537267cd4a..7e8f29ae62 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find/ranges.find.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find/ranges.find.pass.cpp
@@ -131,7 +131,7 @@ constexpr bool test() {
 #if TEST_STD_VER >= 20
   {
     std::vector<std::vector<int>> vec = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
-    auto view = vec | std::views::join;
+    auto view                         = vec | std::views::join;
     assert(std::ranges::find(view.begin(), view.end(), 4) == std::next(view.begin(), 3));
     assert(std::ranges::find(view, 4) == std::next(view.begin(), 3));
   }

``````````

</details>


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


More information about the libcxx-commits mailing list