[libcxx-commits] [libcxx] [libc++] Speed up set_intersection() by fast-forwarding over ranges of non-matching elements with one-sided binary search. (PR #75230)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri May 24 12:17:29 PDT 2024


================
@@ -496,9 +730,9 @@ constexpr bool test() {
       std::ranges::set_intersection(r1.begin(), r1.end(), r2.begin(), r2.end(), out.data(), comp, proj1, proj2);
 
       assert(std::ranges::equal(out, expected, {}, &Data::data));
-      assert(numberOfComp < maxOperation);
-      assert(numberOfProj1 < maxOperation);
-      assert(numberOfProj2 < maxOperation);
+      assert(numberOfComp <= maxOperation);
+      assert(numberOfProj1 <= maxOperation);
+      assert(numberOfProj2 <= maxOperation);
----------------
ldionne wrote:

Why does this need to change? EDIT: Because this was previously incorrect, the spec says "at most 2(N+M)-1 operations", not "less than XXXX operations".

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


More information about the libcxx-commits mailing list