@@ -389,42 +389,32 @@ struct __gen_set_mask
389389
390390 std::size_t __nb = __set_b.size ();
391391
392- // This reference extends the lifetime of a temporary object returned by operator[]
393- // so that it can be safely used with identity projections
394- auto && __val_a = __set_a[__id];
395- auto && __val_a_proj = std::invoke (__proj1, std::forward<decltype (__val_a)>(__val_a));
396-
397- auto __res =
398- oneapi::dpl::__internal::__pstl_lower_bound (__set_b, std::size_t {0 }, __nb, __val_a_proj, __comp, __proj2);
392+ auto __res = oneapi::dpl::__internal::__pstl_lower_bound_idx (__set_b, std::size_t {0 }, __nb, __set_a, __id,
393+ __comp, __proj2, __proj1);
399394 constexpr bool __is_difference = std::is_same_v<_SetTag, oneapi::dpl::unseq_backend::_DifferenceTag>;
400395
401396 // initialization is true in case of difference operation; false - intersection.
402397 bool bres = __is_difference;
403398
404- if (__res == __nb || std::invoke (__comp, __val_a_proj, std::invoke (__proj2, __set_b[__res])))
399+ if (__res == __nb ||
400+ std::invoke (__comp, std::invoke (__proj1, __set_a[__id]), std::invoke (__proj2, __set_b[__res])))
405401 {
406- // there is no __val_a in __set_b, so __set_b in the difference {__set_a}/{__set_b};
402+ // there is no __set_a[__id] in __set_b, so __set_b in the difference {__set_a}/{__set_b};
407403 }
408404 else
409405 {
410- // This reference extends the lifetime of a temporary object returned by operator[]
411- // so that it can be safely used with identity projections
412- auto && __val_b = __set_b[__res];
413- auto && __val_b_proj = std::invoke (__proj2, std::forward<decltype (__val_b)>(__val_b));
414-
415406 // Difference operation logic: if number of duplication in __set_a on left side from __id > total number of
416407 // duplication in __set_b then a mask is 1
417408
418409 // Intersection operation logic: if number of duplication in __set_a on left side from __id <= total number of
419410 // duplication in __set_b then a mask is 1
420411
421412 const std::size_t __count_a_left =
422- __id - oneapi::dpl::__internal::__pstl_left_bound (__set_a, std::size_t {0 }, __id, __val_a_proj, __comp, __proj1) + 1 ;
413+ __id - oneapi::dpl::__internal::__pstl_left_bound_idx (__set_a, std::size_t {0 }, __id, __set_a, __id, __comp, __proj1 , __proj1) + 1 ;
423414
424- const std::size_t __count_b =
425- oneapi::dpl::__internal::__pstl_right_bound (__set_b, __res, __nb, __val_b_proj, __comp, __proj2) -
426- oneapi::dpl::__internal::__pstl_left_bound (__set_b, std::size_t {0 }, __res, __val_b_proj, __comp,
427- __proj2);
415+ const std::size_t __count_b =
416+ oneapi::dpl::__internal::__pstl_right_bound_idx (__set_b, __res, __nb, __set_b, __res, __comp, __proj2, __proj2) -
417+ oneapi::dpl::__internal::__pstl_left_bound_idx (__set_b, std::size_t {0 }, __res, __set_b, __res, __comp, __proj2, __proj2);
428418
429419 if constexpr (__is_difference)
430420 bres = __count_a_left > __count_b; /* difference*/
@@ -713,24 +703,20 @@ struct __gen_set_balanced_path
713703 return std::make_tuple (__merge_path_rng1, __merge_path_rng2, false );
714704 }
715705
716- // This reference extends the lifetime of a temporary object returned by operator[]
717- // so that it can be safely used with identity projections
718- auto && __ele_val = __rng1[__merge_path_rng1 - 1 ];
719- auto && __ele_val_proj = std::invoke (__proj1, std::forward<decltype (__ele_val)>(__ele_val));
720-
721- if (std::invoke (__comp, __ele_val_proj, std::invoke (__proj2, __rng2[__merge_path_rng2])))
706+ if (std::invoke (__comp, std::invoke (__proj1, __rng1[__merge_path_rng1 - 1 ]),
707+ std::invoke (__proj2, __rng2[__merge_path_rng2])))
722708 {
723709 // There is no chance that the balanced path differs from the merge path here, because the previous element of
724710 // rng1 does not match the next element of rng2. We can just return the merge path.
725711 return std::make_tuple (__merge_path_rng1, __merge_path_rng2, false );
726712 }
727713
728714 // find first element of repeating sequence in the first set of the previous element
729- _Index __rng1_repeat_start = oneapi::dpl::__internal::__biased_lower_bound </* __last_bias=*/ true >(
730- __rng1, __rng1_begin, __merge_path_rng1, __ele_val_proj, __comp, __proj1);
715+ _Index __rng1_repeat_start = oneapi::dpl::__internal::__biased_lower_bound_idx </* __last_bias=*/ true >(
716+ __rng1, __rng1_begin, __merge_path_rng1, __rng1, __merge_path_rng1 - 1 , __comp, __proj1 , __proj1);
731717 // find first element of repeating sequence in the second set of the next element
732- _Index __rng2_repeat_start = oneapi::dpl::__internal::__biased_lower_bound </* __last_bias=*/ true >(
733- __rng2, __rng2_begin, __merge_path_rng2, __ele_val_proj, __comp, __proj2);
718+ _Index __rng2_repeat_start = oneapi::dpl::__internal::__biased_lower_bound_idx </* __last_bias=*/ true >(
719+ __rng2, __rng2_begin, __merge_path_rng2, __rng1, __merge_path_rng1 - 1 , __comp, __proj2, __proj1 );
734720
735721 _Index __rng1_repeats = __merge_path_rng1 - __rng1_repeat_start;
736722 _Index __rng2_repeats_bck = __merge_path_rng2 - __rng2_repeat_start;
@@ -748,8 +734,8 @@ struct __gen_set_balanced_path
748734 // Calculate the max location to search in the second set for future repeats, limiting to the edge of the range
749735 _Index __fwd_search_bound = std::min (__merge_path_rng2 + __fwd_search_count, __rng2_end);
750736
751- _Index __balanced_path_intersection_rng2 = oneapi::dpl::__internal::__pstl_upper_bound (
752- __rng2, __merge_path_rng2, __fwd_search_bound, __ele_val_proj, __comp, __proj2);
737+ _Index __balanced_path_intersection_rng2 = oneapi::dpl::__internal::__pstl_upper_bound_idx (
738+ __rng2, __merge_path_rng2, __fwd_search_bound, __rng1, __merge_path_rng1 - 1 , __comp, __proj2, __proj1 );
753739
754740 // Calculate the number of matchable "future" repeats in the second set
755741 _Index __matchable_forward_ele_rng2 = __balanced_path_intersection_rng2 - __merge_path_rng2;
0 commit comments